Fix: 500K iteration SEGV - node pool exhaustion + deadlock
Root cause analysis (via Task agent investigation): - Node pool (512 nodes/class) exhausts at ~500K iterations - Two separate issues identified: 1. Deadlock in sp_freelist_push_lockfree (FREE path) 2. Node pool exhaustion triggering stack corruption (ALLOC path) Fixes applied: 1. Deadlock fix (core/hakmem_shared_pool.c:382-387): - Removed recursive pthread_mutex_lock/unlock in fallback path - Caller (shared_pool_release_slab:772) already holds lock - Prevents deadlock on non-recursive mutex 2. Node pool expansion (core/hakmem_shared_pool.h:77): - Increased MAX_FREE_NODES_PER_CLASS from 512 to 4096 - Supports 500K+ iterations without exhaustion - Prevents stack corruption in hak_tiny_alloc_slow() Test results: - Before: SEGV at 500K with "Node pool exhausted for class 7" - After: 9.44M ops/s, stable, no warnings, no crashes Note: This fixes Mid-Large allocator's SP-SLOT Box, not Phase B C23 code. Phase B (TinyFrontC23Box) remains stable and unaffected. 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -74,7 +74,7 @@ typedef struct {
|
||||
} LockFreeFreeList;
|
||||
|
||||
// Node pool for lock-free allocation (avoid malloc/free)
|
||||
#define MAX_FREE_NODES_PER_CLASS 512 // Pre-allocated nodes per class
|
||||
#define MAX_FREE_NODES_PER_CLASS 4096 // Pre-allocated nodes per class (increased for 500K+ iterations)
|
||||
extern FreeSlotNode g_free_node_pool[TINY_NUM_CLASSES_SS][MAX_FREE_NODES_PER_CLASS];
|
||||
extern _Atomic uint32_t g_node_alloc_index[TINY_NUM_CLASSES_SS];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user