[compiler-rt] [scudo] Add hooks to mark the range of realloc (PR #73883)

Fabio D'Urso via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 11:50:17 PST 2023


================
@@ -17,10 +17,16 @@ extern "C" {
 __attribute__((weak)) const char *__scudo_default_options(void);
 
 // Post-allocation & pre-deallocation hooks.
-// They must be thread-safe and not use heap related functions.
 __attribute__((weak)) void __scudo_allocate_hook(void *ptr, size_t size);
 __attribute__((weak)) void __scudo_deallocate_hook(void *ptr);
 
+// These hooks are used to mark the scope of doing realloc(). Note that the
----------------
fabio-d wrote:

Can you add a more detailed description of the order in which the hooks are called? e.g.

1) `__scudo_realloc_begin_hook` is always called at the beginning of realloc
2) either `__scudo_allocate_hook` or `__scudo_deallocate_hook` or both (`__scudo_deallocate_hook` and then `__scudo_allocate_hook`)
3) `__scudo_realloc_end_hook` is always called at the end

I know that it's easy to see what the code does, but having a comment explicitly describing the intended behavior can be useful in my opinion to distinguish what is official and what is an implementation detail

https://github.com/llvm/llvm-project/pull/73883


More information about the llvm-commits mailing list