Fix: CRITICAL double-allocation bug in trc_linear_carve()
Root Cause: trc_linear_carve() used meta->used as cursor, but meta->used decrements on free, causing already-allocated blocks to be re-carved. Evidence: - [LINEAR_CARVE] used=61 batch=1 → block 61 created - (blocks freed, used decrements 62→59) - [LINEAR_CARVE] used=59 batch=3 → blocks 59,60,61 RE-CREATED! - Result: double-allocation → memory corruption → SEGV Fix Implementation: 1. Added TinySlabMeta.carved (monotonic counter, never decrements) 2. Changed trc_linear_carve() to use carved instead of used 3. carved tracks carve progress, used tracks active count Files Modified: - core/superslab/superslab_types.h: Add carved field - core/tiny_refill_opt.h: Use carved in trc_linear_carve() - core/hakmem_tiny_superslab.c: Initialize carved=0 - core/tiny_alloc_fast.inc.h: Add next pointer validation - core/hakmem_tiny_free.inc: Add drain/free validation Test Results: ✅ bench_random_mixed: 950,037 ops/s (no crash) ✅ Fail-fast mode: 651,627 ops/s (with diagnostic logs) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -22,7 +22,7 @@ typedef struct {
|
||||
} rem_side_entry;
|
||||
|
||||
static rem_side_entry g_rem_side[REM_SIDE_SIZE];
|
||||
int g_remote_side_enable = 0;
|
||||
int g_remote_side_enable = 1; // 強制有効化: ブロックメモリへのnext埋め込みを回避
|
||||
extern int g_debug_remote_guard;
|
||||
static _Atomic int g_remote_scribble_once = 0;
|
||||
static _Atomic uintptr_t g_remote_watch_ptr = 0;
|
||||
|
||||
Reference in New Issue
Block a user