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

tracing & tracing-subscriber have a design defect I believe #3223

Open
vlovich opened this issue Feb 24, 2025 · 5 comments
Open

tracing & tracing-subscriber have a design defect I believe #3223

vlovich opened this issue Feb 24, 2025 · 5 comments
Labels
crate/subscriber Related to the `tracing-subscriber` crate kind/bug Something isn't working

Comments

@vlovich
Copy link

vlovich commented Feb 24, 2025

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:

fn call(&mut self, name: Name) -> Self::Future {
    let span = debug_span!("resolve", host = %name.host);
    let blocking = tokio::task::spawn_blocking(move || { 
        let _enter = span.enter();
        (&*name.host, 0)
            .to_socket_addrs()
            .map(|i| SocketAddrs { iter: i })
    });

    GaiFuture { inner: blocking }
}

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:

#[tokio::main]
async fn main() {
    tracing_subscriber::registry()
        .with(tracing_subscriber::fmt::layer())
        .init();

    let override_default_registry =
        tracing_subscriber::Registry::default().with(tracing_subscriber::fmt::layer());
    async move {
        tracing::info!("Starting request");
        reqwest::Client::new()
            .post("http://localhost:8787/ping")
            .body("")
            .send()
            .await
           .expect("HTTP request failed");
        tracing::info!("Finished request");
    }
    .with_subscriber(override_default_registry)
    .await;
}

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.

@hawkw
Copy link
Member

hawkw commented Feb 24, 2025

Hmm, that doesn't seem right. The guard returned by Span::enter should call the span's do_exit() method when it's dropped:

tracing/tracing/src/span.rs

Lines 1558 to 1570 in bfca546

impl Drop for Entered<'_> {
#[inline(always)]
fn drop(&mut self) {
self.span.do_exit()
}
}
impl Drop for EnteredSpan {
#[inline(always)]
fn drop(&mut self) {
self.span.do_exit()
}
}

The Span::do_exit() method calls exit on the subscriber that was current when the span was created (which is stored by the Span), not the current subscriber on the thread when the guard was dropped:

tracing/tracing/src/span.rs

Lines 1051 to 1054 in bfca546

fn do_exit(&self) {
if let Some(inner) = self.inner.as_ref() {
inner.subscriber.exit(&inner.id);
}

This is designed to prevent precisely the situation you're describing in this issue, so I'm not sure what's gone wrong.

@hawkw
Copy link
Member

hawkw commented Feb 24, 2025

Looking at the panic in hyperium/hyper#3848, I see that and the stack indicates that we are in the span's try_close method:

stack backtrace:
   0: rust_begin_unwind
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5
   1: core::panicking::panic_fmt
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14
   2: <tracing_subscriber::registry::sharded::Registry as tracing_core::subscriber::Subscriber>::try_close
             at /home/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/registry/sharded.rs:350:21
   3: <tracing_subscriber::layer::layered::Layered<L,S> as tracing_core::subscriber::Subscriber>::try_close
             at /home/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/layer/layered.rs:186:12
   4: tracing_core::dispatcher::Dispatch::try_close
             at /home/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-core-0.1.33/src/dispatcher.rs:703:9
   5: <tracing_subscriber::registry::sharded::Registry as tracing_core::subscriber::Subscriber>::exit::{{closure}}
             at /home/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/registry/sharded.rs:303:52
   6: tracing_core::dispatcher::get_default

It looks like the problem is this code in tracing-subscriber's Registry implementation:

if spans.borrow_mut().pop(id) {
dispatcher::get_default(|dispatch| dispatch.try_close(id.clone()));
}

Note that here, in order to call the exit callback on every subscriber Layer above the Registry, we call get_default to get the current default subscriber. The registry implementation assumes that that will return the same subscriber that's processing the exit, but this isn't the case.

One solution, although it has unfortunate performance implications, would be for the Span type's enter and exit code to set its captured subscriber as the thread's default for the duration of the call to enter, exit, or close it, rather than calling those methods directly on the captured Dispatch reference to the subscriber. That way, any code that runs inside the subscriber callbacks will see itself as the current default on that thread.

@hawkw hawkw added kind/bug Something isn't working crate/subscriber Related to the `tracing-subscriber` crate labels Feb 24, 2025
@vlovich
Copy link
Author

vlovich commented Feb 28, 2025

Can the performance be mitigated by checking if the thread being run on is still the same as the one the span was created on and only if there's a difference change the default thread subscriber? Not sure about the relative cost of the thread id check vs changing the TLS variable although maybe I'm missing the cost (I would think changing a single TLS variable is quite cheap on the order of checking the current thread but maybe setting the thread's default dispatcher is more involved)

@arpadav
Copy link

arpadav commented Apr 2, 2025

Hey, I am by no means a Rust expert and don't fully understand the complexity of this issue, but have there any steps toward a resolution for this? I would love to put in a PR rather than just complain, but this isn't necessarily my forte.

I encountered this issue, and what I believe to be tangential issues:

Most issues I find under hyper-util and reqwest, where the maintainers take no interest in accommodating for this panic. They are using the tracing API as expected and shift blame. As a result, this issue continuously pops up in their repos, but they close them and nothing gets fixed at the source.

I'm unsure if these are all 100% related, but I just wanted to make note of it that it seems recurring and prominent.

How I encountered this (somewhat pseudocode)

/// creates a default global logger, appending to file + stdout
fn global_logger() {
  let subscriber: tracing_subscriber::fmt::Subscriber; /* constructed using tracing_subscriber::fmt() */
  tracing::subscriber::set_global_default(subscriber);
}

/// creates a logger to be used in some span, appending to file + stdout
fn build_logger() -> (tracing_core::dispatcher::Dispatch, tracing_appender::non_blocking::WorkerGuard) {
  let (.., guard) = tracing_appender::non_blocking(..);
  let subscriber: tracing_subscriber::fmt::Subscriber; /* constructed using tracing_subscriber::fmt() */
  let dispatch = Dispatch::new(subscriber);
  (dispatch, guard)
}

fn main() {

  // vvv uncommenting this, panics @ reqwest get, hyper_utils client future
  // global_logger();
  // ^^^ uncommenting this, panics @ reqwest get, hyper_utils client future

  let thread_0 = std::thread::spawn(move || {

    // get local spanned logger for this async runtime
    let (dispatch, _guard) = build_logger();
    let _local_default_guard = tracing::dispatcher::set_default(&dispatch);
    let rt = tokio::runtime::Builder::new_current_thread()
        .worker_threads(1)
        .enable_all()
        .build()
        .unwrap();

    // spawn async runtime on this thread
    rt.block_on(async move {
      // perform a reqwest::Client::get here
    });

  });
  thread_0.join().unwrap();
}

full trace:

thread 'tokio-runtime-worker' panicked at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/registry/sharded.rs:350:21:
tried to drop a ref to Id(1), but no such span exists!
stack backtrace:
   0: rust_begin_unwind
             at /rustc/96cfc75584359ae7ad11cc45968059f29e7b44b7/library/std/src/panicking.rs:695:5
   1: core::panicking::panic_fmt
             at /rustc/96cfc75584359ae7ad11cc45968059f29e7b44b7/library/core/src/panicking.rs:75:14
   2: <tracing_subscriber::registry::sharded::Registry as tracing_core::subscriber::Subscriber>::try_close
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/registry/sharded.rs:350:21
   3: <tracing_subscriber::layer::layered::Layered<L,S> as tracing_core::subscriber::Subscriber>::try_close
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/layer/layered.rs:186:12
   4: <tracing_subscriber::layer::layered::Layered<L,S> as tracing_core::subscriber::Subscriber>::try_close
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/layer/layered.rs:186:12
   5: <tracing_subscriber::fmt::Subscriber<N,E,F,W> as tracing_core::subscriber::Subscriber>::try_close
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/fmt/mod.rs:434:9
   6: tracing_core::dispatcher::Dispatch::try_close
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-core-0.1.33/src/dispatcher.rs:703:9
   7: <tracing_subscriber::registry::sharded::Registry as tracing_core::subscriber::Subscriber>::exit::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/registry/sharded.rs:303:52
   8: tracing_core::dispatcher::get_default::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-core-0.1.33/src/dispatcher.rs:395:24
   9: std::thread::local::LocalKey<T>::try_with
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:311:12
  10: tracing_core::dispatcher::get_default
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-core-0.1.33/src/dispatcher.rs:392:5
  11: <tracing_subscriber::registry::sharded::Registry as tracing_core::subscriber::Subscriber>::exit
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/registry/sharded.rs:303:17
  12: <tracing_subscriber::layer::layered::Layered<L,S> as tracing_core::subscriber::Subscriber>::exit
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/layer/layered.rs:162:9
  13: <tracing_subscriber::layer::layered::Layered<L,S> as tracing_core::subscriber::Subscriber>::exit
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/layer/layered.rs:162:9
  14: <tracing_subscriber::fmt::Subscriber<N,E,F,W> as tracing_core::subscriber::Subscriber>::exit
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.19/src/fmt/mod.rs:419:9
  15: tracing_core::dispatcher::Dispatch::exit
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-core-0.1.33/src/dispatcher.rs:636:9
  16: tracing::span::Span::do_exit
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/span.rs:1054:13
  17: <tracing::span::Entered as core::ops::drop::Drop>::drop
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/span.rs:1562:9
  18: core::ptr::drop_in_place<tracing::span::Entered>
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:523:1
  19: <hyper_util::client::legacy::connect::dns::GaiResolver as tower_service::Service<hyper_util::client::legacy::connect::dns::Name>>::call::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/dns.rs:126:9
  20: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/blocking/task.rs:42:21
  21: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/core.rs:331:17
  22: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/loom/std/unsafe_cell.rs:16:9
  23: tokio::runtime::task::core::Core<T,S>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/core.rs:320:13
  24: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/harness.rs:532:19
  25: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  26: std::panicking::try::do_call
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:587:40
  27: __rust_try
  28: std::panicking::try
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:550:19
  29: std::panic::catch_unwind
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359:14
  30: tokio::runtime::task::harness::poll_future
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/harness.rs:520:18
  31: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/harness.rs:209:27
  32: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/harness.rs:154:15
  33: tokio::runtime::task::raw::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/raw.rs:271:5
  34: tokio::runtime::task::raw::RawTask::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/raw.rs:201:18
  35: tokio::runtime::task::UnownedTask<S>::run
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/task/mod.rs:500:9
  36: tokio::runtime::blocking::pool::Task::run
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/blocking/pool.rs:161:9
  37: tokio::runtime::blocking::pool::Inner::run
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/blocking/pool.rs:511:17
  38: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/blocking/pool.rs:469:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

thread '<unnamed>' panicked at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/dns.rs:149:21:
gai background task failed: JoinError::Panic(Id(17), "tried to drop a ref to Id(1), but no such span exists!", ...)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/96cfc75584359ae7ad11cc45968059f29e7b44b7/library/std/src/panicking.rs:695:5
   1: core::panicking::panic_fmt
             at /rustc/96cfc75584359ae7ad11cc45968059f29e7b44b7/library/core/src/panicking.rs:75:14
   2: <hyper_util::client::legacy::connect::dns::GaiFuture as core::future::future::Future>::poll::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/dns.rs:149:21
   3: core::task::poll::Poll<T>::map
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/task/poll.rs:54:43
   4: <hyper_util::client::legacy::connect::dns::GaiFuture as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/dns.rs:142:9
   5: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/map.rs:55:37
   6: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
   8: hyper_util::client::legacy::connect::dns::resolve::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/dns.rs:298:28
   9: hyper_util::client::legacy::connect::http::HttpConnector<R>::call_async::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/http.rs:541:18
  10: <hyper_util::client::legacy::connect::http::HttpConnector<R> as tower_service::Service<http::uri::Uri>>::call::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/http.rs:474:62
  11: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  12: <hyper_util::client::legacy::connect::http::HttpConnecting<R> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/connect/http.rs:638:9
  13: <hyper_tls::client::HttpsConnector<T> as tower_service::Service<http::uri::Uri>>::call::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-tls-0.6.0/src/client.rs:150:34
  14: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  15: <hyper_tls::client::HttpsConnecting<T> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-tls-0.6.0/src/client.rs:179:9
  16: reqwest::connect::ConnectorService::connect_with_maybe_proxy::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.15/src/connect.rs:435:41
  17: reqwest::connect::with_timeout::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.15/src/connect.rs:611:11
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  19: <hyper_util::service::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/service/oneshot.rs:55:38
  20: <F as futures_core::future::TryFuture>::try_poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/future.rs:92:9
  21: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/try_future/into_future.rs:34:9
  22: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/map.rs:55:37
  23: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
  24: <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
  25: <F as futures_core::future::TryFuture>::try_poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/future.rs:92:9
  26: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/try_future/into_future.rs:34:9
  27: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/map.rs:55:37
  28: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
  29: <futures_util::future::try_future::MapOk<Fut,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
  30: <F as futures_core::future::TryFuture>::try_poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/future.rs:92:9
  31: <futures_util::future::try_future::try_flatten::TryFlatten<Fut,<Fut as futures_core::future::TryFuture>::Ok> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/try_future/try_flatten.rs:49:61
  32: <futures_util::future::try_future::TryFlatten<Fut1,Fut2> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
  33: <futures_util::future::try_future::AndThen<Fut1,Fut2,F> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/lib.rs:86:13
  34: <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/either.rs:108:32
  35: <hyper_util::common::lazy::Lazy<F,R> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/common/lazy.rs:64:20
  36: futures_util::future::future::FutureExt::poll_unpin
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/mod.rs:558:9
  37: <futures_util::future::select::Select<A,B> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/select.rs:118:35
  38: hyper_util::client::legacy::client::Client<C,B>::one_connection_for::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/client.rs:434:49
  39: hyper_util::client::legacy::client::Client<C,B>::connection_for::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/client.rs:385:61
  40: hyper_util::client::legacy::client::Client<C,B>::try_send_request::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/client.rs:280:14
  41: hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/client.rs:248:70
  42: <hyper_util::client::legacy::client::ResponseFuture as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-util-0.1.11/src/client/legacy/client.rs:703:9
  43: <reqwest::async_impl::client::PendingRequest as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.15/src/async_impl/client.rs:2673:53
  44: <reqwest::async_impl::client::Pending as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.15/src/async_impl/client.rs:2643:51
  45: crate::tests::test::{{closure}}::{{closure}}::{{closure}}
             at ./src/tests/test.rs:554:47
  46: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  47: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:733:54
  48: tokio::task::coop::with_budget
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/task/coop/mod.rs:167:5
  49: tokio::task::coop::budget
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/task/coop/mod.rs:133:5
  50: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:733:25
  51: tokio::runtime::scheduler::current_thread::Context::enter
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:432:19
  52: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:732:36
  53: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:820:68
  54: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/context/scoped.rs:40:9
  55: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/context.rs:180:26
  56: std::thread::local::LocalKey<T>::try_with
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:311:12
  57: std::thread::local::LocalKey<T>::with
             at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:275:15
  58: tokio::runtime::context::set_scheduler
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/context.rs:180:9
  59: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:820:27
  60: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:720:19
  61: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:200:28
  62: tokio::runtime::context::runtime::enter_runtime
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/context/runtime.rs:65:16
  63: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/scheduler/current_thread/mod.rs:188:9
  64: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/runtime.rs:368:47
  65: tokio::runtime::runtime::Runtime::block_on
             at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.1/src/runtime/runtime.rs:342:13
  66: crate::tests::test::{{closure}}::{{closure}}
             at ./src/tests/test.rs:527:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@arpadav
Copy link

arpadav commented Apr 3, 2025

https://github.com/arpadav/tracing-span-bug/

Made this, showcasing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/subscriber Related to the `tracing-subscriber` crate kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants