[scudo] Call __scudo_deallocate_hook on reallocations.
authorGuillaume Chelfi <chelfi@google.com>
Tue, 14 Feb 2023 18:44:37 +0000 (18:44 +0000)
committerChia-hung Duan <chiahungduan@google.com>
Tue, 14 Feb 2023 18:44:38 +0000 (18:44 +0000)
commit4e3dac6f0a4c419ee0cd575407e95f3833a01a2e
tree479c4f400297c2e9e7c839c7e6609dbef11c6375
parent6c7894a8e65289d5e3a655afc1747a06ed8553e0
[scudo] Call __scudo_deallocate_hook on reallocations.

Scudo is expected to call __scudo_allocate_hook on allocations, and
__scudo_deallocate_hook on deallocations, but it's behavior is not
clear on reallocations. Currently, non-trivial reallocations call
__scudo_allocate_hook but never __scudo_deallocate_hook. We should
prefer either calling both, none, or a dedicated
hook (__scudo_reallocate_hook, for instance).

This patch implements the former, and adds a unit test to enforce
those expectations.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D141407
compiler-rt/lib/scudo/standalone/allocator_config.h
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
compiler-rt/lib/scudo/standalone/tests/scudo_hooks_test.cpp [new file with mode: 0644]