-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Rust runtime fails trying to create threads with requested stack size < TLS size #6233
Comments
I made a mistake. The workaround should actually be to add __pthread_get_minstack(&attr) to the requested size in src/rt/sync/rust_thread.cpp. It's still not very pleasing. |
This is the bug in glibc http://sourceware.org/bugzilla/show_bug.cgi?id=11787 |
Still relevant, but it's an upstream bug. Removing E-easy |
Triage: we still call |
Triage: still a bug even with the pure Rust runtime. #[feature(thread_local)];
#[allow(dead_code)];
#[cfg(crash)]
static SIZE: uint = 1 << 20; // 1 MB
#[cfg(not(crash))]
static SIZE: uint = 1 << 10; // 1 KB
#[thread_local]
static FOO: [u8, .. SIZE] = [0, .. SIZE];
fn main() {} With task '<unnamed>' failed at 'assertion failed: `(left == right) && (right == left)` (left: `22i32`, right: `0i32`)', /home/huon/rust/src/libstd/rt/thread.rs:211
failed at 'called `Option::unwrap()` on a `None` value', /home/huon/rust/src/libstd/option.rs:133 and without that I'll attempt to fix it now. |
(The above crash appears to not happen on Mac OSX; I'm on Linux.) I opened #11284; but I don't think that work-around is complete enough to close this. |
If there is a lot of data in thread-local storage some implementations of pthreads (e.g. glibc) fail if you don't request a stack large enough -- by adjusting for the minimum size we guarantee that our stacks are always large enough. Issue rust-lang#6233.
If there is a lot of data in thread-local storage some implementations of pthreads (e.g. glibc) fail if you don't request a stack large enough -- by adjusting for the minimum size we guarantee that our stacks are always large enough. Issue #6233.
My patch caused people linking errors ( |
add manual_ok_or lint Implements partially rust-lang#5923 changelog: add lint manual_ok_or
Linking with certain external libraries can inflate the required amount of thread local storage to astronomical proportions. When the Rust runtime tries to create its threads, it requests a stack size independent of the TLS size, which can lead to pthread_create() failing with EINVAL when the stack size is smaller than the TLS size. This was apparently an issue for the Go runtime as well (http://sourceware.org/ml/libc-alpha/2012-06/msg00175.html).
A potential workaround is to add __static_tls_size (+ possibly a guard page) to the requested stack size, but it's arguably a bug in glibc that TLS comes out of the requested stack, instead of being added to it. This solution is also admittedly not very pleasing...
The text was updated successfully, but these errors were encountered: