Skip to content

Commit 3182c4f

Browse files
committed
Add some docs
1 parent 15e2df0 commit 3182c4f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Zend/zend_alloc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
171171
#endif
172172

173173
#ifdef __SANITIZE_ADDRESS__
174+
175+
/*
176+
Poisoning uses the following rules:
177+
* Always poison memory (re)allocated by private (non-ZEND_API) allocation functions before returning it
178+
* Unpoison memory (re)allocated by public (ZEND_API) allocation functions before returning within the ZEND_API function
179+
* Always poison freed memory
180+
* Always poison unused memory during reallocation (where new_size < old_size)
181+
* When accessing private heap structures and fields, always unpoison before accessing and repoison immediately after
182+
* An exception to the above (for simplicity) is the main heap datastructure,
183+
which is poisoned only when entering a ZEND_API function and repoisoned before exiting.
184+
* When working with custom handlers, remember that the tracked_malloc implementation
185+
removes the custom handlers, re-enters the current Zend allocator function,
186+
then re-sets the custom handlers, so when invoking custom handlers always
187+
remember that the heap may be poisoned after invocation.
188+
*/
189+
174190
# include <sanitizer/asan_interface.h>
175191

176192
# if 0

0 commit comments

Comments
 (0)