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

ctor cause fatal runtime error: thread::set_current should only be called once per thread #307

Open
haicoder opened this issue Aug 22, 2024 · 5 comments

Comments

@haicoder
Copy link

haicoder commented Aug 22, 2024

rust version

rustc 1.82.0-nightly (5aea14073 2024-08-20)

system

Debian GNU/Linux 10 (buster)

ctor version

0.2.8

Code

// src/bin/test.rs
fn main() {
}

#[ctor::ctor]
fn setup() {
    println!("enter")
}

Output

enter
fatal runtime error: thread::set_current should only be called once per thread
@ganeshrvel
Copy link

Same issue occurred in my project after updating to Rust 1.81.0.
I resolved it using the libc-print crate.

@eloff
Copy link

eloff commented Sep 18, 2024

I'm seeing the same thing after updating to Rust 1.81.0

@mmastrac
Copy link
Owner

Unfortunately the builtin println is not safe to use in ctor or dtor -- libc_print is specifically designed for this: https://crates.io/crates/libc-print.

@photowey
Copy link

photowey commented Oct 7, 2024

I'm seeing the same thing after updating to Rust 1.81.0.

@phil-skillwon
Copy link

I'm seeing the same thing after updating to Rust 1.81.0

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

6 participants