Skip to content

Bad interaction between tracing-error and tracing #1565

@asonix

Description

@asonix

Bug Report

Version

├── tracing v0.1.27
│   ├── tracing-attributes v0.1.16 (proc-macro)
│   └── tracing-core v0.1.20
├── tracing-error v0.1.2
│   ├── tracing v0.1.27 (*)
│   └── tracing-subscriber v0.2.22
│       ├── tracing v0.1.27 (*)
│       ├── tracing-core v0.1.20 (*)
│       ├── tracing-log v0.1.2
│       │   └── tracing-core v0.1.20 (*)
│       └── tracing-serde v0.1.2
│           └── tracing-core v0.1.20 (*)
└── tracing-subscriber v0.2.22 (*)

Platform

Linux firestar 5.11.0-34-generic #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Description

When passing a type containing tracing-error's SpanTrace to a span's record method, A rwlock is attemped to lock while it's already held, which would result in a deadlock if it didn't panic instead.

Repro:

[dependencies]
tracing = "0.1"
tracing-error = "0.1"
tracing-subscriber = { version = "0.2", features = ["fmt"] }
use tracing_error::{ErrorLayer, SpanTrace};
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
    let subscriber = Registry::default()
        .with(env_filter)
        .with(ErrorLayer::default())
        .with(tracing_subscriber::fmt::layer());

    tracing::subscriber::set_global_default(subscriber)?;

    let span = tracing::info_span!("Blows up!", exception = tracing::field::Empty);
    let entered = span.enter();

    let context = SpanTrace::capture();

    // this line goes boom
    span.record("exception", &tracing::field::debug(&context));

    drop(entered);
    Ok(())
}

Originally reported here: LukeMathWalker/tracing-actix-web#36

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions