This is to support D101204.
We introduced a new class AllocatorAPI that can be shared with MSan and DFSan.
Paths
| Differential D101599
[msan] Refactor allocator instantiation AbandonedPublic Authored by stephan.yichao.zhao on Apr 30 2021, 12:10 AM.
Details
Diff Detail
Event Timelinevitalybuka added inline comments.
stephan.yichao.zhao retitled this revision from [msan] Refactor allocator instantiation to [msan] Refactor allocator instantiation. Comment Actionsupdate
Comment Actions Regarding the main point of the patch, I understand that's you are doing this to avoid duplicating code.
Probably check with @eugenis before fixing my comments if he is ok with this approach.
Comment Actions I'm not sure if this is worth the code savings. One way of thinking about it - can it be used in ASan? TSan? Usually, you do not start factoring out common parts until you are about to add a 3rd copy of a thing. Perhaps a more incremental approach would be better. For example, most of the Allocate method - handling of allocator cache, fallback allocator, out of memory check - is clearly common code, but Reallocate logic seems a bit too complicated and sanitizer-specific. I especially dislike the hooks, the make the code hard to follow. requested_size works great as a common allocator concept, but I think you'll have issues if you try applying this refactoring to ASan, which does not use metadata.
Comment Actions Thank you for the feedback. I feel the following takeaways make sense
Although Allocate and Deallocate have some similar code, but because of Thread and ThreadLocalMallocStorage, those 10-20 lines of code need a template too... To support D101204, adding a separate allocator seems better because of the above trade-offs. I would deprecate this one.
Revision Contents
Diff 341935 compiler-rt/lib/msan/msan.h
compiler-rt/lib/msan/msan_allocator.cpp
compiler-rt/lib/msan/msan_interceptors.cpp
compiler-rt/lib/msan/msan_new_delete.cpp
compiler-rt/lib/sanitizer_common/CMakeLists.txt
compiler-rt/lib/sanitizer_common/sanitizer_allocator_api.h
|
clang-tidy: warning: '__msan::MSanAllocatorAPI' has virtual functions but non-virtual destructor [clang-diagnostic-non-virtual-dtor]
not useful