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

dtor - broken by upgrading tokio from 1.38.0 to 1.39.1 - use of std::thread::current() is not possible after the thread's local data has been destroyed #304

Open
Tockra opened this issue Jul 25, 2024 · 1 comment

Comments

@Tockra
Copy link

Tockra commented Jul 25, 2024

Hello,

in the past I used dtor in combination with tokio to clean up my test environment after the test execution.
Everything worked fine.

But after I removed my Cargo.lock and recreated it, I received alway following message :

thread '<unnamed>' panicked at library/std/src/thread/mod.rs:741:19:
use of std::thread::current() is not possible after the thread's local data has been destroyed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
error: test failed, to rerun pass `--test auth`

Here the simple testfile:

// tests/my-int.rs
#[dtor]
fn on_shutdown() {
    tokio::runtime::Builder::new_current_thread()
        .enable_all()
        .build()
        .unwrap()
        .block_on(async {
            println!("HELLO WORLD");
        });
}

I'm not sure where the origin of this problem is. Is it a ctor problem or a problem of a other specific async library?
Here you see the diff of my Cargo.lock:
https://www.diffchecker.com/N8nESogY/

Sorry for the form, but I found no better solution to provide the differences, without copying them step by step.

T

@Tockra
Copy link
Author

Tockra commented Jul 25, 2024

After some try and error I found out it worked until tokio 1.38.0
With 1.39.1 the error occurs.

Here is a minimal example. Just type cargo test and see the above code failing:
(Without fixed Cargo.lock):
https://github.com/Tockra/playground/tree/dtor-no-changes-not-working

(With fixed Cargo.lock, working):
https://github.com/Tockra/playground/tree/dtor-downgraded-tokio-working

  • Problem occurs with M2 macbook on macos.
  • No problem with X86 CPU on windows:
  • Problem occurs on X86 Debian GNU/Linux 11 system

@Tockra Tockra changed the title dtor current thread problems since update dtor - broken by upgrading tokio from 1.38.0 to 1.39.1 - use of std::thread::current() is not possible after the thread's local data has been destroyed Jul 26, 2024
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

No branches or pull requests

1 participant