Skip to content

Commit 7e87699

Browse files
marxinzebreus
authored andcommitted
move the EXIT_CALLED check before every __deregister_frame call
1 parent 2203487 commit 7e87699

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
@@ -261,13 +261,6 @@ extern "C" fn atexit_handler() {
261261

262262
impl Drop for UnwindRegistry {
263263
fn drop(&mut self) {
264-
// We don't want to deregister frames in UnwindRegistry::Drop as that could be called during
265-
// program shutdown and can collide with release_registered_frames and lead to
266-
// crashes.
267-
if EXIT_CALLED.load(Ordering::SeqCst) {
268-
return;
269-
}
270-
271264
if self.published {
272265
unsafe {
273266
// libgcc stores the frame entries as a linked list in decreasing sort order
@@ -287,6 +280,12 @@ impl Drop for UnwindRegistry {
287280

288281
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
289282
{
283+
// We don't want to deregister frames in UnwindRegistry::Drop as that could be called during
284+
// program shutdown and can collide with release_registered_frames and lead to
285+
// crashes.
286+
if EXIT_CALLED.load(Ordering::SeqCst) {
287+
return;
288+
}
290289
__deregister_frame(*registration as *const _);
291290
}
292291
}

0 commit comments

Comments
 (0)