Skip to content
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

c++: assert (written == len) is not informative error message for write failure #721

Open
james-rms opened this issue Nov 13, 2022 · 5 comments
Labels
c++ feature New feature or request

Comments

@james-rms
Copy link
Collaborator

james-rms commented Nov 13, 2022

Description
Currently we assert that the write succeeds in FileWriter, here:

assert(written == size);

This is an error that can occur in production. if the underlying storage medium fills up, and the user needs some kind of trail to debug why.

  • Version: v0.6.0
  • Platform: Ubuntu Linux

Steps To Reproduce
Create a tmpfs with a limited max size, try writing past its size limit.

Expected Behavior
Some kind of "storage is full" error

Actual Behavior
"Assertion failed (size == written)"

@james-rms james-rms added bug Something isn't working feature New feature or request and removed bug Something isn't working labels Nov 13, 2022
@jhurliman
Copy link
Contributor

Is the storage medium filling up the only possible cause of this error?

@james-rms
Copy link
Collaborator Author

No, this generalizes to all the errors that could result from calling fwrite. On linux, there's a list here: https://man7.org/linux/man-pages/man3/fputc.3p.html

@jhurliman
Copy link
Contributor

Got it. Is the idea that we check for size != written and then call errno() + strerror()?

@james-rms
Copy link
Collaborator Author

Yes, modulo thread-safety concerns. We may need some OS-specific stuff here.

@jhurliman
Copy link
Contributor

errno() on Linux uses thread-local storage. I don't know about other platforms, and it will need some sort of #ifdef for Windows I imagine.

@jtbandes jtbandes added the c++ label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ feature New feature or request
Development

No branches or pull requests

3 participants