@@ -104,25 +104,24 @@ impl LockMetadata {
104
104
105
105
#[ cfg( feature = "backtrace" ) ]
106
106
{
107
- let mut ip = None ;
107
+ let mut symbol_ptr = None ;
108
108
// Find the first frame which is after `debug_sync` (or which is in our tests) and use
109
109
// that as the mutex construction site. Note that the first few frames may be in
110
110
// `backtrace`, so we have to ignore those.
111
111
let sync_mutex_constr_regex = regex:: Regex :: new ( r"lightning.*debug_sync.*new" ) . unwrap ( ) ;
112
112
let mut found_debug_sync = false ;
113
- for frame in backtrace. frames ( ) {
114
- // If a constructor was inlined we should take the frame in which it was inlined
115
- // (as its specific to the callsite), thus we look at the last available symbol,
116
- // which the `backtrace` docs say will be the caller.
117
- let symbol_name = frame. symbols ( ) . last ( ) . unwrap ( ) . name ( ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
118
- if !sync_mutex_constr_regex. is_match ( symbol_name) {
119
- if found_debug_sync {
120
- ip = Some ( frame. ip ( ) as usize as u64 ) ;
121
- break ;
122
- }
123
- } else { found_debug_sync = true ; }
113
+ ' trace_walk: for frame in backtrace. frames ( ) {
114
+ for symbol in frame. symbols ( ) {
115
+ let symbol_name = symbol. name ( ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
116
+ if !sync_mutex_constr_regex. is_match ( symbol_name) {
117
+ if found_debug_sync {
118
+ symbol_ptr = Some ( symbol. addr ( ) . unwrap ( ) as usize as u64 ) ;
119
+ break ' trace_walk;
120
+ }
121
+ } else { found_debug_sync = true ; }
122
+ }
124
123
}
125
- lock_idx = ip . unwrap ( ) ;
124
+ lock_idx = symbol_ptr . unwrap ( ) ;
126
125
LOCKS_INIT . call_once ( || { unsafe { LOCKS = Some ( StdMutex :: new ( HashMap :: new ( ) ) ) ; } } ) ;
127
126
if let Some ( metadata) = unsafe { LOCKS . as_ref ( ) } . unwrap ( ) . lock ( ) . unwrap ( ) . get ( & lock_idx) {
128
127
return Arc :: clone ( & metadata) ;
0 commit comments