mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-02-02 12:52:53 +01:00
Fix a race condition
There is a window of time between the munmap and the tls_cache being marked as destroyed, where there could be a bad access to memory that has been unmapped/freed. Reorder the code a bit to close the window. Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
This commit is contained in:
parent
cf2f3d3b75
commit
52ca68c770
1 changed files with 2 additions and 2 deletions
|
@ -66,10 +66,10 @@ trace_cache_free (void *arg)
|
|||
PTHREAD_DESTRUCTOR_ITERATIONS - cache->dtor_count);
|
||||
return;
|
||||
}
|
||||
tls_cache_destroyed = 1;
|
||||
tls_cache = NULL;
|
||||
munmap (cache->frames, (1u << cache->log_size) * sizeof(unw_tdep_frame_t));
|
||||
mempool_free (&trace_cache_pool, cache);
|
||||
tls_cache = NULL;
|
||||
tls_cache_destroyed = 1;
|
||||
Debug(5, "freed cache %p\n", cache);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue