File tree 2 files changed +9
-19
lines changed
2 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,8 @@ impl Backtrace {
303
303
// Capture a backtrace which start just before the function addressed by
304
304
// `ip`
305
305
fn create ( ip : usize ) -> Backtrace {
306
- let _lock = lock ( ) ;
306
+ // SAFETY: We don't attempt to lock this reentrantly.
307
+ let _lock = unsafe { lock ( ) } ;
307
308
let mut frames = Vec :: new ( ) ;
308
309
let mut actual_start = None ;
309
310
unsafe {
@@ -408,7 +409,8 @@ impl Capture {
408
409
// Use the global backtrace lock to synchronize this as it's a
409
410
// requirement of the `backtrace` crate, and then actually resolve
410
411
// everything.
411
- let _lock = lock ( ) ;
412
+ // SAFETY: We don't attempt to lock this reentrantly.
413
+ let _lock = unsafe { lock ( ) } ;
412
414
for frame in self . frames . iter_mut ( ) {
413
415
let symbols = & mut frame. symbols ;
414
416
let frame = match & frame. frame {
Original file line number Diff line number Diff line change @@ -8,27 +8,15 @@ use crate::io;
8
8
use crate :: io:: prelude:: * ;
9
9
use crate :: path:: { self , Path , PathBuf } ;
10
10
use crate :: sync:: atomic:: { self , Ordering } ;
11
- use crate :: sys :: mutex:: Mutex ;
11
+ use crate :: sys_common :: mutex:: StaticMutex ;
12
12
13
13
/// Max number of frames to print.
14
14
const MAX_NB_FRAMES : usize = 100 ;
15
15
16
- pub fn lock ( ) -> impl Drop {
17
- struct Guard ;
18
- static LOCK : Mutex = Mutex :: new ( ) ;
19
-
20
- impl Drop for Guard {
21
- fn drop ( & mut self ) {
22
- unsafe {
23
- LOCK . unlock ( ) ;
24
- }
25
- }
26
- }
27
-
28
- unsafe {
29
- LOCK . lock ( ) ;
30
- Guard
31
- }
16
+ // SAFETY: Don't attempt to lock this reentrantly.
17
+ pub unsafe fn lock ( ) -> impl Drop {
18
+ static LOCK : StaticMutex = StaticMutex :: new ( ) ;
19
+ LOCK . lock ( )
32
20
}
33
21
34
22
/// Prints the current backtrace.
You can’t perform that action at this time.
0 commit comments