-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Hard to trace errors if raise multiple errors on MT #8299
Comments
I guess we should just have a global lock around the exception printer to stdout. It's a rare thing to happen anyways so shouldn't incur any performance penalty, I hope |
Unwinding the stack, extracting the file:line info from DWARF tables are already a high cost. Adding a mutex to print errors shouldn't add that much. Especially since in production apps it should be redirected to a logger anyway. |
I think my code is not good enough to indicate the problem. The mess of error log is bad, not the worst. The worst is that errors can generate error. I have no idea to design a minimal straightforward code for the worst case, but we can take the issue #8288 as an example. Sometimes I got the error when I ran this code.
This error is generated by other errors. The bugs which we want to resolve are hided by new error, and it is extremely hard to debug. @ysbaddaden The cost of mutex depends on how frequently the mutex is competed by different threads/fibers. There is no reason to frequently unwind stacks in production app. |
On my M2 I can't reproduce the interleaved messages anymore, but this is what I get:
|
I do reproduce on Linux x86_64 with MT enabled. The problem is that different threads compete to write their message with many write to STDERR. We might work around the issue by writing the whole message into a buffer, then writing once to STDERR? |
The code
The output
Crystal version
The text was updated successfully, but these errors were encountered: