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

Thread name with null crashes with "Illegal instruction" #32475

Closed
diwic opened this issue Mar 25, 2016 · 4 comments
Closed

Thread name with null crashes with "Illegal instruction" #32475

diwic opened this issue Mar 25, 2016 · 4 comments

Comments

@diwic
Copy link
Contributor

diwic commented Mar 25, 2016

Trying the following example on playpen (notice the \0 inside the thread name)

fn main() {
    std::thread::Builder::new().name("chi\0ld1".to_string()).spawn(|| {
        println!("Hello, world!");
    }).unwrap().join().unwrap();
}

Playpen output:

thread '<unnamed>' panicked at 'thread name may not contain interior null bytes', ../src/libstd/sys/unix/thread.rs:90
note: Run with `RUST_BACKTRACE=1` for a backtrace.
fatal runtime error: Could not unwind stack, error = 5
playpen: application terminated abnormally with signal 4 (Illegal instruction)

Both on stable and nightly.

@diwic
Copy link
Contributor Author

diwic commented Mar 25, 2016

Patch: #32476

Manishearth pushed a commit to Manishearth/rust that referenced this issue Mar 26, 2016
…t-lang#32475)

Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.

Signed-off-by: David Henningsson <diwic@ubuntu.com>
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 26, 2016
…ichton

Fix unsound behaviour with null characters in thread names (issue rust-lang#32475)

Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 26, 2016
…ichton

Fix unsound behaviour with null characters in thread names (issue rust-lang#32475)

Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.
@pmarcelll
Copy link
Contributor

It can be closed, right?

@sfackler
Copy link
Member

Yep

@diwic
Copy link
Contributor Author

diwic commented Mar 28, 2016

I was leaving it open because I did not know if it was going to be beta nominated or not.

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

3 participants