Missing line numbers in stack traces with Tokio and panic!()

I'm having some trouble with the receipt of backtraces/stacktraces when handling panic!() , and I suspect that it may have something to do with Tokio. Here's the setup I have:

// panic.rs
static INIT: Once = Once::new();
pub fn setup() {
    INIT.call_once(|| {
        let next = panic::take_hook();
        panic::set_hook(Box::new(move |info| {
            let backtrace = backtrace::Backtrace::new();
            error!(message = "panic", "\n{:?}\n", backtrace);

// lib.rs
pub async fn start()  {
    let spawn_1 = tokio::spawn(async move {
        my_function_panic(); // Call 1

    let spawn_2 = tokio::spawn(async move {
        my_function_panic(); // Call 2

fn my_function_panic() {
    panic!("panic on purpose")

My issue is that the stack trace only seems to indicate the start of the trace, thread 'tokio-runtime-worker' panicked at 'panic on purpose', hub/src/lib.rs:68:5.

Here full logs:

I'm particularly interested in these lines:

services-hub-1  |   18:     0x55bbd66a34ef - hub::my_function_panic::hc38316ec909fd2ac
services-hub-1  |   19:     0x55bbd6650df4 - hub::start::{{closure}}::{{closure}}::hd8adc338b2bb8070

What I'm finding is that the line numbers are missing.

Here are the environmental variables I'm using at runtime:


If I use a function instead of a closure, the function name does not appear at all :thinking:

pub async fn start()  {
    let spawn_1 = tokio::spawn(handle_thread_1());

    let spawn_2 = tokio::spawn(handle_thread_2());

async fn handle_thread_1() {
async fn handle_thread_2() {
    6: hub::my_function_panic
   7: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
   8: tokio::runtime::task::core::Core<T,S>::poll

Is this a release build? Just from experimenting a bit it seems like async fns spawned that way don't get included in the backtrace unless debuginfo is at 1 or higher

You can adjust the debug info level for a cargo profile in the Cargo.toml

1 Like

Thanks you @semicoleon ! it is that.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.