mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
Under C++ object lifetime and strict aliasing rules, accessing typed objects requires that an object of that type actually exists at the memory location. Previously, the Block structure stored prev and next offset values, where the prev field overlapped with the usable space of the preceding block to save space. When the predecessor was allocated, user payload was written directly to this overlapping space, complicating object lifetime management. A key issue arose during reallocation (like in-place shrinking), where the allocator needed to manipulate block boundaries (e.g., splitting a block) while user payload was still actively residing in that memory. This caused undefined behavior due to accessing typed Block members that collided with the user's active objects. This patch eliminates the problem by always treating blocks as raw bytes accessed through a byte-backed proxy (BlockRef). Instead of constructing or casting to typed Block structures, metadata is read and written using aligned byte-copy operations (inline_memcpy). This decouples block manipulation from C++ object lifetime rules, guaranteeing safe access without violating strict aliasing. Assisted-by: AI Tools, checked manually |
||
|---|---|---|
| .. | ||
| CMakeLists.txt | ||
| freelist_heap_fuzz.cpp | ||
| hashtable_fuzz.cpp | ||
| uint_fuzz.cpp | ||
| weak_avl_fuzz.cpp | ||