Open jameslarus opened 4 years ago
Yea, this needs a fix.
Can't promise it any time soon though -- we are overbooked.
Also, not sure about relative priority, as this only affects programs with a really large number of large allocations.
Patches are welcome.
Yes, it is true that this primarily affects programs with large number of large allocations (and there are many), but remember that the execution path to determine that a pointer did not come from the allocator (eg alloca) always goes through this function, which locks the list. The locking is a bottleneck on heavily multithreaded programs, even if the list of large blocks is small. I clearly understand that it is not at the top of the list of things to fix, but hopefully it doesn't fall off the bottom.
The secondary allocator for large memory blocks (sanitizer_allocator_secondary.h) maintains a linked list of large memory blocks which is iterated with a lock held in
GetBlockBegin
. The cost of this iteration can be large in a program that uses large regions of memory and a sanitizer that invokesPointerIsMine
frequently (e.g. Memoro). The latter test would be more efficiently implemented with a balanced search tree to determine if a pointer is contained within one of the blocks allocated by the secondary allocator.