Skip to content

Commit

Permalink
Rollup merge of rust-lang#100007 - ChrisDenton:dtor-inline-never, r=m…
Browse files Browse the repository at this point in the history
…ichaelwoerister

Never inline Windows dtor access

Inlining can cause problem If used in a Rust dylib. See rust-lang#44391.

r? `@Mark-Simulacrum`
  • Loading branch information
Dylan-DPC authored Aug 11, 2022
2 parents 72d0be4 + 847f461 commit 5b2ad6e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/std/src/sys/windows/thread_local_dtor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
#[thread_local]
static mut DESTRUCTORS: Vec<(*mut u8, unsafe extern "C" fn(*mut u8))> = Vec::new();

// Ensure this can never be inlined because otherwise this may break in dylibs.
// See #44391.
#[inline(never)]
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
DESTRUCTORS.push((t, dtor));
}

#[inline(never)] // See comment above
/// Runs destructors. This should not be called until thread exit.
pub unsafe fn run_keyless_dtors() {
// Drop all the destructors.
Expand Down

0 comments on commit 5b2ad6e

Please sign in to comment.