Skip to content

Commit 700a11a

Browse files
committed
Aborting when before_wait function panics
1 parent 776f222 commit 700a11a

File tree

1 file changed

+7
-2
lines changed
  • library/std/src/sys/sgx/waitqueue

1 file changed

+7
-2
lines changed

library/std/src/sys/sgx/waitqueue/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod unsafe_list;
1818

1919
use crate::num::NonZeroUsize;
2020
use crate::ops::{Deref, DerefMut};
21+
use crate::panic::{self, AssertUnwindSafe};
2122
use crate::time::Duration;
2223

2324
use super::abi::thread;
@@ -157,7 +158,9 @@ impl WaitQueue {
157158
}));
158159
let entry = guard.queue.inner.push(&mut entry);
159160
drop(guard);
160-
before_wait();
161+
if let Err(_e) = panic::catch_unwind(AssertUnwindSafe(|| before_wait())) {
162+
rtabort!("Panic before wait on wakeup event")
163+
}
161164
while !entry.lock().wake {
162165
// don't panic, this would invalidate `entry` during unwinding
163166
let eventset = rtunwrap!(Ok, usercalls::wait(EV_UNPARK, WAIT_INDEFINITE));
@@ -181,7 +184,9 @@ impl WaitQueue {
181184
wake: false,
182185
}));
183186
let entry_lock = lock.lock().queue.inner.push(&mut entry);
184-
before_wait();
187+
if let Err(_e) = panic::catch_unwind(AssertUnwindSafe(|| before_wait())) {
188+
rtabort!("Panic before wait on wakeup event or timeout")
189+
}
185190
usercalls::wait_timeout(EV_UNPARK, timeout, || entry_lock.lock().wake);
186191
// acquire the wait queue's lock first to avoid deadlock.
187192
let mut guard = lock.lock();

0 commit comments

Comments
 (0)