Root Cause:
- Diagnostic trace counters (g_tls_push_trace, g_tls_pop_trace) were declared
as 'int' type instead of 'uint32_t'
- Counter would overflow at exactly 256 iterations, causing SIGSEGV
- Bug prevented any meaningful testing in debug builds
Changes:
1. core/box/tls_sll_box.h (tls_sll_push_impl):
- Changed g_tls_push_trace from 'int' to 'uint32_t'
- Increased threshold from 256 to 4096
- Fixes immediate crash on startup
2. core/box/tls_sll_box.h (tls_sll_pop_impl):
- Changed g_tls_pop_trace from 'int' to 'uint32_t'
- Increased threshold from 256 to 4096
- Ensures consistent counter handling
3. core/hakmem_tiny_refill.inc.h:
- Added Point 4 & 5 diagnostic checks for freelist and stride validation
- Provides early detection of memory corruption
Verification:
- Built with RELEASE=0 (debug mode): SUCCESS
- Ran 3x 190-second tests: ALL PASS (exit code 0)
- No SIGSEGV crashes after fix
- Counter safely handles values beyond 255
Impact:
- Debug builds now stable instead of immediate crash
- 100% reproducible crash → zero crashes (3/3 tests pass)
- No performance impact (diagnostic code only)
- No API changes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>