File tree Expand file tree Collapse file tree 2 files changed +9
-19
lines changed Expand file tree Collapse file tree 2 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,8 @@ impl Backtrace {
303303 // Capture a backtrace which start just before the function addressed by
304304 // `ip`
305305 fn create ( ip : usize ) -> Backtrace {
306- let _lock = lock ( ) ;
306+ // SAFETY: We don't attempt to lock this reentrantly.
307+ let _lock = unsafe { lock ( ) } ;
307308 let mut frames = Vec :: new ( ) ;
308309 let mut actual_start = None ;
309310 unsafe {
@@ -408,7 +409,8 @@ impl Capture {
408409 // Use the global backtrace lock to synchronize this as it's a
409410 // requirement of the `backtrace` crate, and then actually resolve
410411 // everything.
411- let _lock = lock ( ) ;
412+ // SAFETY: We don't attempt to lock this reentrantly.
413+ let _lock = unsafe { lock ( ) } ;
412414 for frame in self . frames . iter_mut ( ) {
413415 let symbols = & mut frame. symbols ;
414416 let frame = match & frame. frame {
Original file line number Diff line number Diff line change @@ -8,27 +8,15 @@ use crate::io;
88use crate :: io:: prelude:: * ;
99use crate :: path:: { self , Path , PathBuf } ;
1010use crate :: sync:: atomic:: { self , Ordering } ;
11- use crate :: sys :: mutex:: Mutex ;
11+ use crate :: sys_common :: mutex:: StaticMutex ;
1212
1313/// Max number of frames to print.
1414const MAX_NB_FRAMES : usize = 100 ;
1515
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 ( )
3220}
3321
3422/// Prints the current backtrace.
You can’t perform that action at this time.
0 commit comments