Skip to content

Commit 079f999

Browse files
committedJul 3, 2024
Move unique_thread_exit call to lang_start_internal so it is not in a generic function, and wrap it in catch_unwind
1 parent 47d0cbc commit 079f999

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎std/src/rt.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ fn lang_start_internal(
144144
rtabort!("drop of the panic payload panicked");
145145
});
146146
panic::catch_unwind(cleanup).map_err(rt_abort)?;
147+
// Guard against multple threads calling `libc::exit` concurrently.
148+
// See the documentation for `unique_thread_exit` for more information.
149+
panic::catch_unwind(|| crate::sys::common::exit_guard::unique_thread_exit())
150+
.map_err(rt_abort)?;
147151
ret_code
148152
}
149153

@@ -161,8 +165,5 @@ fn lang_start<T: crate::process::Termination + 'static>(
161165
argv,
162166
sigpipe,
163167
);
164-
// Guard against multple threads calling `libc::exit` concurrently.
165-
// See the documentation for `unique_thread_exit` for more information.
166-
crate::sys::common::exit_guard::unique_thread_exit();
167168
v
168169
}

0 commit comments

Comments
 (0)