Skip to content

pthread_exit no longer works in panic=abort #101469

Closed
@programmerjake

Description

@programmerjake

I tried this code:
https://rust.godbolt.org/z/M5Pz1rjnd

#![feature(c_unwind)]
#![no_main]
use std::ffi::{c_void, c_int, c_char};
use std::ptr::null_mut;

extern "C-unwind" {
    fn pthread_exit(v: *mut c_void) -> !;
}

#[no_mangle]
pub unsafe extern "C-unwind" fn main(_argc: c_int, _argv: *mut *mut c_char) {
    unsafe {pthread_exit(null_mut())}
}

I expected to see this happen: exits with exit code 0 as documented for pthread_exit

Instead, this happened: aborts with double panic

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (8c6ce6b91 2022-09-02)
binary: rustc
commit-hash: 8c6ce6b91b172f77c795a74bfeaf74b865146b3f
commit-date: 2022-09-02
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

sorry, i can't figure out how to get a backtrace from godbolt.org, it doesn't seem to allow setting environment variables.

This bug serms to be caused by #96959

@rust-lang/wg-ffi-unwind

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-c_unwind`#![feature(c_unwind)]`WG-ffi-unwindWorking group: FFI unwind

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions