-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Usage of non-async signal safe functions in signal handlers #9437
Comments
the window's function is fine. since it's not an async signal handler, but a fault recovery filter. as long as the libc and ios manage to avoid throwing programming errors around, it won't cause any issues. the that leaves the sigdie_handler. most of the signals it handles are already fatal. if we happen to be in a state where we tried to call malloc but couldn't get the lock, we might freeze waiting for the thread instead of dieing immediately. annoying, but not particularly devastating. others, like those handled by that does leave ideas are welcome. |
Ok.
Ok. Theoretically there is a chance of the fputs not working if a previous fputs was interrupted, but as Julia is terminating its not the end of the world if the message doesn't happen this time. Next time hopefully the interrupt won't happen in exactly the same place.
yes, thats the usual fix, but of course write is a lot less convenient than printf. One solution to the backtrace problem I have seen is to pre-allocate the space on the way down the call chain, so backtraces can work without allocation. But its a lot of work to make everything do that, and to release the memory again correctly, and of course it reserves memory that we hope will never get used. I think it would also be hard to apply to C/Fortran functions in system libraries. |
Prompted by #9063 I did a quick check of all the signal handlers (that I can find) for unsafe calls (not in this list). These are the ones I found from quick (mostly Linux only) inspection.
sigint_handler()
usesfputs()
several times.sigdie_handler()
usesios_printf()
which does not protect its buffer manipulations from signal interrupts.I also noticed that the windows _exception_handler() uses
ios_puts()
a lot but I am not sure if its ok on windows.I have not had time to check that
jl_errorf()
andjl_throw()
are safe but they are used a lot.The text was updated successfully, but these errors were encountered: