Skip to content

Commit c48e850

Browse files
marxinzebreus
authored andcommitted
move the EXIT_CALLED check before every __deregister_frame call
1 parent 09daeee commit c48e850

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/compiler/src/engine/unwind/systemv.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ extern "C" fn atexit_handler() {
255255

256256
impl Drop for UnwindRegistry {
257257
fn drop(&mut self) {
258-
// We don't want to deregister frames in UnwindRegistry::Drop as that could be called during
259-
// program shutdown and can collide with release_registered_frames and lead to
260-
// crashes.
261-
if EXIT_CALLED.load(Ordering::SeqCst) {
262-
return;
263-
}
264-
265258
if self.published {
266259
unsafe {
267260
// libgcc stores the frame entries as a linked list in decreasing sort order
@@ -281,6 +274,12 @@ impl Drop for UnwindRegistry {
281274

282275
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
283276
{
277+
// We don't want to deregister frames in UnwindRegistry::Drop as that could be called during
278+
// program shutdown and can collide with release_registered_frames and lead to
279+
// crashes.
280+
if EXIT_CALLED.load(Ordering::SeqCst) {
281+
return;
282+
}
284283
__deregister_frame(*registration as *const _);
285284
}
286285
}

0 commit comments

Comments
 (0)