-
-
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
Crash when using IO from finalizer inside Task #21442
Comments
The error is correct; task switches (which includes most I/O) are not allowed in finalizers. |
One workaround is to |
Can we make it so that all task switches invoked from finalizers automatically schedule the task instead of trying to run inside the finalizer? Wouldn't that typically have the desired effect? |
that's possible, but it would mean wrapping all finalizers in a Task |
Would it be possible to do it lazily at the time when the finalizer tries to do the switch? |
Otherwise, it seems fine to just improve the error message here. |
AFAICT the lazy approach would be very hard to implement, since it would require relocating everything in the stack since the call to the finalizer. |
Ok, in that case, let's just improve the error message to make it clear what the problem is – i.e. that you cannot do I/O or any other task switching from a finalizer, and maybe some kind of bread crumb to how to explicitly schedule a new task from a finalizer. |
Thanks for the tip using The above error appeared to place me in a state where the REPL would no longer evaluate what I was typing. The following seems to place me in the same state:
After this, it seems like the only thing I could do is hit Ctrl-C, which causes Julia to terminate. Is that the expected behavior? (I'm using 0.5.1) |
previously we couldn't reliably tell the difference between a failure to context switch and an explicitly scheduled error in the former case, we often need to undo some prior action by moving the code for the later into Julia, we can reliably run the necessary undo action when required fix #21442
previously we couldn't reliably tell the difference between a failure to context switch and an explicitly scheduled error in the former case, we often need to undo some prior action by moving the code for the later into Julia, we can reliably run the necessary undo action when required fix #21442
previously we couldn't reliably tell the difference between a failure to context switch and an explicitly scheduled error in the former case, we often need to undo some prior action by moving the code for the later into Julia, we can reliably run the necessary undo action when required fix #21442
previously we couldn't reliably tell the difference between a failure to context switch and an explicitly scheduled error in the former case, we often need to undo some prior action by moving the code for the later into Julia, we can reliably run the necessary undo action when required fix #21442
A finalizer which uses print() was called from a Task that was created with @async, resulting in a crash with the following errors:
The text was updated successfully, but these errors were encountered: