-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Stack overflow when tls_callback
called on x86_64-pc-windows-gnu
#140798
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
Comments
This comment has been minimized.
This comment has been minimized.
The code for the dll is this one: https://github.com/nagisa/rust_libloading/blob/master/src/test_helpers.rs Compile it with
Then write some code to load and unload it: fn main() {
let join_handles: Vec<_> = (0..16)
.map(|_| {
std::thread::spawn(|| unsafe {
for _ in 0..10000 {
// Use libloading, or write LoadLibrary & FreeLibrary yourself.
let lib = Library::new("libtest_helpers.module").expect("open library");
let _: Symbol<unsafe extern "C" fn(u32) -> u32> =
lib.get(b"test_identity_u32").expect("get fn");
lib.close().expect("close is successful");
}
})
})
.collect();
for handle in join_handles {
handle.join().expect("thread should succeed");
}
} This issue doesn't always trigger. I have found that, debug it with |
This comment has been minimized.
This comment has been minimized.
Maybe #127912 , I guess. |
Looking at the stack trace, we panic here rust/library/std/src/sys/thread_local/key/windows.rs Lines 114 to 115 in e964cca
and then when trying to check whether we're panicking while inside another panic and we need to abort, we hit the same code path rust/library/std/src/panicking.rs Line 433 in e964cca
It seems that the issue can occur in more than just windows-gnu, but windows-gnu simply more likely to exhaust tls indices than others (somehow.. I'm not entirely clear on this part) cc @joboet @rustbot label: -E-needs-mcve -E-needs-bisection +S-has-bisection -needs-triage +A-thread-locals +A-panic |
You're right. I asked the question about |
Recently the CI of
libloading
could not pass. I tested it and found this issue. It only occurs on*-gnu
target, not*-msvc
or*-gnullvm
target. I have noticed that*-msvc
and*-gnullvm
has native thread local support, but*-gnu
does not. Is it the cause?Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: