fix pointer aliasing in malloc dispatch tables in InitNativeAllocatorDispatch#70
fix pointer aliasing in malloc dispatch tables in InitNativeAllocatorDispatch#70rdevshp wants to merge 1 commit into
Conversation
|
Please explain what this is addressing. |
|
Inside MallocInitImpl, it first calls InitNativeAllocatorDispatch, which sets both globals->current_dispatch_table and globals->default_dispatch_table to the address of globals->malloc_dispatch_table. Then it calls InstallHooks when MallocDebug is enabled, which then calls 1. LoadSharedLibrary and then 2. FinishInstallHooks. LoadSharedLibrary loads the globals->malloc_dispatch_table with the malloc debug functions. Due to the aliasing, globals->current_dispatch_table and globals->default_dispatch_table are also set to the malloc debug functions. Then in FinishInstallHooks, debug_initialize is called in the following code This means that debug_initialize is not going to be able to properly save prev_dispatch due to the aliasing as it is already overridden by LoadSharedLibrary. |
|
I don't understand why you're using |
|
I have removed atomic_store. |
|
Basically globals->malloc_dispatch_table is the dispatch table to store allocator hooks, not for storing the underlying allocator implementations. |
The aliased malloc dispatch table can cause issues with malloc debug.