-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error checking on fclose #19600
Labels
Comments
bung87
added a commit
to bung87/Nim
that referenced
this issue
May 27, 2022
ringabout
added a commit
that referenced
this issue
Sep 2, 2022
capocasa
pushed a commit
to capocasa/Nim
that referenced
this issue
Mar 31, 2023
* fix nim-lang#19600 No error checking on fclose * add IOError to open
capocasa
pushed a commit
to capocasa/Nim
that referenced
this issue
Mar 31, 2023
…" (nim-lang#20297) This reverts commit 04e4a5e.
ringabout
added a commit
that referenced
this issue
Nov 22, 2024
Araq
pushed a commit
that referenced
this issue
Nov 23, 2024
narimiran
pushed a commit
that referenced
this issue
Jan 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that there is no error checking when closing a file. In lib/system/io.nim:309 the result of c_fclose(f) is discarded.
However, the C stdlib uses buffering and effectively writes small files on fclose. For example it only discovers that there is no space left on device at that point. The error is typically propagated as the result of fclose.
Example
Small file
Long file
Current Output
nothing for small file
for long file
Expected Output
for both.
Possible Solution
Raise exception when result of fclose is not 0.
Note that ferror does not seem to be updated by fclose, which make checkErr useless in that context.
Additional Information
Note: this was discovered after reading https://blog.sunfishcode.online/bugs-in-hello-world/
The text was updated successfully, but these errors were encountered: