Timeout: lift VERIFY -> ASSERT to prevent crashes in release builds#10789
Merged
julianbrost merged 3 commits intomasterfrom Apr 16, 2026
Merged
Timeout: lift VERIFY -> ASSERT to prevent crashes in release builds#10789julianbrost merged 3 commits intomasterfrom
VERIFY -> ASSERT to prevent crashes in release builds#10789julianbrost merged 3 commits intomasterfrom
Conversation
Timeout class usagesVERIFY -> ASSERT to prevent crashes in release builds
Member
Author
|
After all the debugging and head-scratching about this in the last 2 days offline, the problem was spotted by @jschmidt-icinga and the mysterious crash exclusively on aarch64 is caused by compiler optimizations and Asio's use of thread-local storage with Fibers that can migrate between threads. See the updated PR description for more details. Instead of completely removing the assertion, I have lifted it to |
`strand.running_in_this_thread()` relies on thread-local storage internally, and may return false positives if the coroutine is resumed in a different thread than it was suspended in. In debug builds, this is not problem, since there's no TLS optimization done by the compiler, but in release builds, the compiler might cache the address of the thread-local variable read before the coroutine suspension, and thus potentially reuse the same address in a different thread after resumption, which would cause `running_in_this_thread()` to return false or even crash (but we didn't see any crashes related to this). So, perform the assertion only in debug builds to prevent potential wrong usages of the `Timeout` class. For more details, see [^1][^2][^3]. [^1]: chriskohlhoff/asio#1366 [^2]: https://bugs.llvm.org/show_bug.cgi?id=19177 [^3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461
jschmidt-icinga
approved these changes
Apr 16, 2026
Contributor
jschmidt-icinga
left a comment
There was a problem hiding this comment.
Looks fine to me. 👍
Member
|
I hate computers, and C++ in particular. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
strand.running_in_this_thread()relies on thread-local storage internally, and may return false positives if the coroutine is resumed on a different thread than it was suspended in. In debug builds, this is not a problem, since there's no TLS optimization done by the compiler, but in release builds, the compiler might cache the address of the thread-local variable read before the coroutine suspension, and thus potentially reuse the same address in a different thread after resumption, which would causerunning_in_this_thread()to return false or even crash (but we didn't see any crashes related to this). So, perform the assertion only in debug builds to prevent potential wrong usages of theTimeoutclass. For more details, see 123.To verify the bug, you can apply the following patch to the
OTelclass:Crush Dumps
fixes #10783
Footnotes
https://github.com/chriskohlhoff/asio/issues/1366 ↩
https://bugs.llvm.org/show_bug.cgi?id=19177 ↩
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461 ↩