Files
hakmem/core/box/front_gate_classifier.d
Moe Charm (CI) d8168a2021 Fix C7 TLS SLL header restoration regression + Document Larson MT race condition
## Bug Fix: Restore C7 Exception in TLS SLL Push

**File**: `core/box/tls_sll_box.h:309`

**Problem**: Commit 25d963a4a (Code Cleanup) accidentally reverted the C7 fix by changing:
```c
if (class_idx != 0 && class_idx != 7) {  // CORRECT (commit 8b67718bf)
if (class_idx != 0) {                     // BROKEN (commit 25d963a4a)
```

**Impact**: C7 (1024B class) header restoration in TLS SLL push overwrote next pointer at base[0], causing corruption.

**Fix**: Restored `&& class_idx != 7` check to prevent header restoration for C7.

**Why C7 Needs Exception**:
- C7 uses offset=0 (stores next pointer at base[0])
- User pointer is at base+1
- Next pointer MUST NOT be overwritten by header restoration
- C1-C6 use offset=1 (next at base[1]), so base[0] header restoration is safe

## Investigation: Larson MT Race Condition (SEPARATE ISSUE)

**Finding**: Larson still crashes with 3+ threads due to UNRELATED multi-threading race condition in unified cache freelist management.

**Root Cause**: Non-atomic freelist operations in `TinySlabMeta`:
```c
typedef struct TinySlabMeta {
    void* freelist;    //  NOT ATOMIC
    uint16_t used;     //  NOT ATOMIC
} TinySlabMeta;
```

**Evidence**:
```
1 thread:   PASS (1.88M - 41.8M ops/s)
2 threads:  PASS (24.6M ops/s)
3 threads:  SEGV (race condition)
4+ threads:  SEGV (race condition)
```

**Status**: C7 fix is CORRECT. Larson crash is separate MT issue requiring atomic freelist implementation.

## Documentation Added

Created comprehensive investigation reports:
- `LARSON_CRASH_ROOT_CAUSE_REPORT.md` - Full technical analysis
- `LARSON_DIAGNOSTIC_PATCH.md` - Implementation guide
- `LARSON_INVESTIGATION_SUMMARY.md` - Executive summary
- `LARSON_QUICK_REF.md` - Quick reference
- `verify_race_condition.sh` - Automated verification script

## Next Steps

Implement atomic freelist operations for full MT safety (7-9 hour effort):
1. Make `TinySlabMeta.freelist` atomic with CAS loop
2. Audit 87 freelist access sites
3. Test with Larson 8+ threads

🔧 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 02:15:34 +09:00

44 lines
1.8 KiB
Makefile

core/box/front_gate_classifier.o: core/box/front_gate_classifier.c \
core/box/front_gate_classifier.h core/box/../tiny_region_id.h \
core/box/../hakmem_build_flags.h core/box/../tiny_box_geometry.h \
core/box/../hakmem_tiny_superslab_constants.h \
core/box/../hakmem_tiny_config.h core/box/../ptr_track.h \
core/box/../hakmem_super_registry.h core/box/../hakmem_tiny_superslab.h \
core/box/../superslab/superslab_types.h \
core/hakmem_tiny_superslab_constants.h \
core/box/../superslab/superslab_inline.h \
core/box/../superslab/superslab_types.h core/box/../tiny_debug_ring.h \
core/box/../tiny_remote.h core/box/../hakmem_tiny_superslab.h \
core/box/../superslab/superslab_inline.h \
core/box/../hakmem_build_flags.h core/box/../hakmem_internal.h \
core/box/../hakmem.h core/box/../hakmem_config.h \
core/box/../hakmem_features.h core/box/../hakmem_sys.h \
core/box/../hakmem_whale.h core/box/../hakmem_tiny_config.h \
core/box/../pool_tls_registry.h
core/box/front_gate_classifier.h:
core/box/../tiny_region_id.h:
core/box/../hakmem_build_flags.h:
core/box/../tiny_box_geometry.h:
core/box/../hakmem_tiny_superslab_constants.h:
core/box/../hakmem_tiny_config.h:
core/box/../ptr_track.h:
core/box/../hakmem_super_registry.h:
core/box/../hakmem_tiny_superslab.h:
core/box/../superslab/superslab_types.h:
core/hakmem_tiny_superslab_constants.h:
core/box/../superslab/superslab_inline.h:
core/box/../superslab/superslab_types.h:
core/box/../tiny_debug_ring.h:
core/box/../tiny_remote.h:
core/box/../hakmem_tiny_superslab.h:
core/box/../superslab/superslab_inline.h:
core/box/../hakmem_build_flags.h:
core/box/../hakmem_internal.h:
core/box/../hakmem.h:
core/box/../hakmem_config.h:
core/box/../hakmem_features.h:
core/box/../hakmem_sys.h:
core/box/../hakmem_whale.h:
core/box/../hakmem_tiny_config.h:
core/box/../pool_tls_registry.h: