Skip to content
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

Fix deadlock with tracing-error + fmt::Subscriber #2882

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mladedav
Copy link
Contributor

Motivation

#1565

Solution

I've added a method to the FormatFields implementation with a provided default implementation based on what was already in the add_fields method. This is potentially a breaking change in a subtle manner as anyone who has manually implemented the add_fields method will most likely also want to implement this.

When fields should be printed, they are first printed to a new instance and then they are merged with the original.

When `fmt::Debug` implementation contains a `Span` which tries to access
the span's extensions, this can cause a deadlock if the extensions are
already locked by the subscriber.

This is circumvented by creating a string representation before the lock
is held and then combining this representation with any that was in the
span previously.
@mladedav mladedav requested review from yaahc, a team, hawkw and davidbarsky as code owners February 17, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant