-
Notifications
You must be signed in to change notification settings - Fork 755
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
tracing & tracing-subscriber have a design defect I believe #3223
Comments
Hmm, that doesn't seem right. The guard returned by Lines 1558 to 1570 in bfca546
The Lines 1051 to 1054 in bfca546
This is designed to prevent precisely the situation you're describing in this issue, so I'm not sure what's gone wrong. |
Looking at the panic in hyperium/hyper#3848, I see that and the stack indicates that we are in the span's
It looks like the problem is this code in tracing/tracing-subscriber/src/registry/sharded.rs Lines 302 to 304 in bfca546
Note that here, in order to call the exit callback on every subscriber One solution, although it has unfortunate performance implications, would be for the |
Version
tracing 0.1.41
tracing-subscriber 0.3.19
Platform
I'm pretty sure all of them, but definitely verified on Linux 6.12.9-arch1-1
Description
Using with_subscriber will trigger a panic if the async block creates a span & enters it on a different thread that will target the default subscriber. I believe both the with_subscriber AND the enter off-thread scenario are idiomatic. The reason for the crash is that the span.enter() try's recording the span exit into the default subscriber which isn't aware of it since it's registered by the scoped subscriber.
I encountered this with hyper which in GaiResolver has a block like:
This pattern seems pretty idiomatic: https://docs.rs/tracing/0.1.41/tracing/struct.Span.html#method.or_current
A simple repro on Linux (which uses GaiResolver) is:
Tried filing upstream but the author there confirmed it's likely an issue in this crate: hyperium/hyper#3848 (comment)
Either
with_subscriber
has a fatal flaw or the idiomatic pattern needs to be clarified on how to actually make it safe for the above snippet.The text was updated successfully, but these errors were encountered: