@@ -439,16 +439,20 @@ mod dladdr;
439
439
/// Each resolve() implementation allocates and caches several megabytes worth of symbols,
440
440
/// clear_symbol_cache tries to reclaim that cached memory.
441
441
/// Note: for now, only the Gimli implementation is able to clear its cache.
442
- pub fn clear_symbol_cache ( ) {
443
- clear_imp ( )
442
+ #[ cfg( feature = "std" ) ]
443
+ pub fn clear_symbol_cache ( ) {
444
+ let _guard = crate :: lock:: lock ( ) ;
445
+ unsafe {
446
+ clear_imp ( )
447
+ }
444
448
}
445
449
446
450
cfg_if:: cfg_if! {
447
451
if #[ cfg( all( windows, target_env = "msvc" , feature = "dbghelp" ) ) ] {
448
452
mod dbghelp;
449
453
use self :: dbghelp:: resolve as resolve_imp;
450
454
use self :: dbghelp:: Symbol as SymbolImp ;
451
- fn noop_clear_symbol_cache( ) { }
455
+ unsafe fn noop_clear_symbol_cache( ) { }
452
456
use noop_clear_symbol_cache as clear_imp;
453
457
} else if #[ cfg( all(
454
458
feature = "std" ,
@@ -473,7 +477,7 @@ cfg_if::cfg_if! {
473
477
use self :: coresymbolication:: resolve as resolve_imp;
474
478
use self :: coresymbolication:: Symbol as SymbolImp ;
475
479
476
- fn noop_clear_symbol_cache( ) { }
480
+ unsafe fn noop_clear_symbol_cache( ) { }
477
481
use noop_clear_symbol_cache as clear_imp;
478
482
} else if #[ cfg( all( feature = "libbacktrace" ,
479
483
any( unix, all( windows, not( target_vendor = "uwp" ) , target_env = "gnu" ) ) ,
@@ -483,7 +487,7 @@ cfg_if::cfg_if! {
483
487
use self :: libbacktrace:: resolve as resolve_imp;
484
488
use self :: libbacktrace:: Symbol as SymbolImp ;
485
489
486
- fn noop_clear_symbol_cache( ) { }
490
+ unsafe fn noop_clear_symbol_cache( ) { }
487
491
use noop_clear_symbol_cache as clear_imp;
488
492
} else if #[ cfg( all( unix,
489
493
not( target_os = "emscripten" ) ,
@@ -492,14 +496,14 @@ cfg_if::cfg_if! {
492
496
use self :: dladdr_resolve:: resolve as resolve_imp;
493
497
use self :: dladdr_resolve:: Symbol as SymbolImp ;
494
498
495
- fn noop_clear_symbol_cache( ) { }
499
+ unsafe fn noop_clear_symbol_cache( ) { }
496
500
use noop_clear_symbol_cache as clear_imp;
497
501
} else {
498
502
mod noop;
499
503
use self :: noop:: resolve as resolve_imp;
500
504
use self :: noop:: Symbol as SymbolImp ;
501
505
502
- fn noop_clear_symbol_cache( ) { }
506
+ unsafe fn noop_clear_symbol_cache( ) { }
503
507
use noop_clear_symbol_cache as clear_imp;
504
508
}
505
509
}
0 commit comments