Fix Issue 18024 - checkedint.Warn should be @safe (alternative)#6369
Fix Issue 18024 - checkedint.Warn should be @safe (alternative)#6369wilzbach wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @wilzbach! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#6369" |
|
Why not |
The synchronized statement wraps a statement with a mutex to synchronize access among multiple threads which if I understood your point was that another thread thread writing from somewhere else to stderr is unsafe. However, I just checked http://www.unix.org/whitepapers/reentrant.html
Also Lines 2844 to 2846 in 2d87546 but if you don't trust that one, even |
It's more subtle than that. Having any reference at all to You already sidestep this issue by having the reference to |
|
@JackStouffer as far as I understand we fixed the ref-counting of
Imho we can even remove the |
Is it? I don't see that happening anywhere but a |
Yeah, it's how the Warn.hookOpCmp(lhs, rhs);
assert(0);(though I was confusing things and thought that this PR touches Abort directly whereas it only touched Anyhow, printing to stderr should be @safe and AFAICT it's now @safe and if it still isn't we have a serious problem. |
|
Well, your program is no longer going to segfault (I think) but there can still be bad data races. Since This is true even if you were to |
|
In the meantime the LockingWriter has been made thread-safe, but it's still not formally @safe. @thewilsonator what do you think? Can we fix this long-outstanding issue with this trick? |
| thread_suspendAll; | ||
| scope(exit) thread_resumeAll; | ||
| scope(failure) assert(0, "Thread suspension while printing'" ~ msg ~ "' from CheckedInt failed."); | ||
| // this can be done @safe-ly, because it happens just before the program terminates |
There was a problem hiding this comment.
Warn just logs right? Whats this about program termination?
thewilsonator
left a comment
There was a problem hiding this comment.
Other than the slightly confused comment, LGTM.
|
This has been fixed in: #7909 |
So this stops the world while printing the exception.
Imho
lockingTextWritershouldn't require such hacks :/Alternative to #5928