Fix: Add missing superslab_allocate() declaration
Root cause identified by Task agent investigation: - superslab_allocate() called without declaration in 2 files - Compiler assumes implicit int return type (C99 standard) - Actual signature returns SuperSlab* (64-bit pointer) - Pointer truncated to 32-bit int, then sign-extended to 64-bit - Results in corrupted pointer and segmentation fault Mechanism of corruption: 1. superslab_allocate() returns 0x00005555eba00000 2. Compiler expects int, reads only %eax: 0xeba00000 3. movslq %eax,%rbp sign-extends with bit 31 set 4. Result: 0xffffffffeba00000 (invalid pointer) 5. Dereferencing causes SEGFAULT Files fixed: 1. hakmem_tiny_superslab_internal.h - Added box/ss_allocation_box.h (fixes superslab_head.c via transitive include) 2. hakmem_super_registry.c - Added box/ss_allocation_box.h Warnings eliminated: - "implicit declaration of function 'superslab_allocate'" - "type of 'superslab_allocate' does not match original declaration" - "code may be misoptimized unless '-fno-strict-aliasing' is used" Test results: - larson_hakmem now runs without segfault ✓ - Multiple test runs confirmed stable ✓ - 2 threads, 4 threads: All passing ✓ Impact: - CRITICAL severity bug (affects all SuperSlab expansion) - Intermittent (depends on memory layout ~50% probability) - Now FIXED completely 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "hakmem_super_registry.h"
|
||||
#include "hakmem_tiny_superslab.h"
|
||||
#include "box/ss_allocation_box.h" // For superslab_allocate() declaration
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h> // munmap for incompatible SuperSlab eviction
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include "hakmem_tiny_superslab.h"
|
||||
#include "box/ss_hot_cold_box.h"
|
||||
#include "box/ss_allocation_box.h" // CRITICAL: For superslab_allocate() declaration (fixes implicit int assumption)
|
||||
#include "hakmem_super_registry.h"
|
||||
#include "hakmem_tiny.h"
|
||||
#include "hakmem_tiny_config.h"
|
||||
|
||||
@ -6,7 +6,8 @@ hakmem_super_registry.o: core/hakmem_super_registry.c \
|
||||
core/superslab/../hakmem_tiny_superslab_constants.h \
|
||||
core/superslab/../hakmem_tiny_config.h core/tiny_debug_ring.h \
|
||||
core/hakmem_build_flags.h core/tiny_remote.h \
|
||||
core/hakmem_tiny_superslab_constants.h
|
||||
core/hakmem_tiny_superslab_constants.h core/box/ss_allocation_box.h \
|
||||
core/hakmem_tiny_superslab.h
|
||||
core/hakmem_super_registry.h:
|
||||
core/hakmem_tiny_superslab.h:
|
||||
core/superslab/superslab_types.h:
|
||||
@ -20,3 +21,5 @@ core/tiny_debug_ring.h:
|
||||
core/hakmem_build_flags.h:
|
||||
core/tiny_remote.h:
|
||||
core/hakmem_tiny_superslab_constants.h:
|
||||
core/box/ss_allocation_box.h:
|
||||
core/hakmem_tiny_superslab.h:
|
||||
|
||||
Reference in New Issue
Block a user