Skip to content

fix: release fd slot on failed file open#238

Open
beeget wants to merge 1 commit into
TheThirdOne:masterfrom
beeget:fix/file_fd_stuck
Open

fix: release fd slot on failed file open#238
beeget wants to merge 1 commit into
TheThirdOne:masterfrom
beeget:fix/file_fd_stuck

Conversation

@beeget

@beeget beeget commented May 14, 2026

Copy link
Copy Markdown

This pull request improves error handling in the openFile method of SystemIO.java by ensuring that file descriptors are properly closed if a FileNotFoundException occurs during file open operations. This helps prevent resource leaks when file operations fail.

file_path: .asciz  "./file_that_doesnt_exist"


li a7, 1024 # Open
la a0, file_path
li a1, 0 # read-only
ecall # ret a0 = -1 because the file doesn't exist

li a7, 1024 # Open
la a0, file_path
li a1, 1 # write-only, it should create the file
ecall # ret a0 = -1, instead of creating the file and returning the correct fd, since the fd was never released from the first read-only open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant