|
|
291c84a1a7
|
Add Tiny Alloc Gatekeeper Box for unified malloc entry point
Core Changes:
- New file: core/box/tiny_alloc_gate_box.h
* Thin wrapper around malloc_tiny_fast() with diagnostic hooks
* TinyAllocGateContext structure for size/class_idx/user/base/bridge information
* tiny_alloc_gate_diag_enabled() - ENV-controlled diagnostic mode
* tiny_alloc_gate_validate() - Validates class_idx/header/meta consistency
* tiny_alloc_gate_fast() - Main gatekeeper function
* Zero performance impact when diagnostics disabled
- Modified: core/box/hak_wrappers.inc.h
* Added #include "tiny_alloc_gate_box.h" (line 35)
* Integrated gatekeeper into malloc wrapper (lines 198-200)
* Diagnostic mode via HAKMEM_TINY_ALLOC_GATE_DIAG env var
Design Rationale:
- Complements Free Gatekeeper Box: Together they provide entry/exit hooks
- Validates allocation consistency at malloc time
- Enables Bridge + BASE/USER conversion validation in debug mode
- Maintains backward compatibility: existing behavior unchanged
Validation Features:
- tiny_ptr_bridge_classify_raw() - Verifies Superslab/Slab/meta lookup
- Header vs meta class consistency check (rate-limited, 8 msgs max)
- class_idx validation via hak_tiny_size_to_class()
- All validation logged but non-blocking (observation points for Guard)
Testing:
- All smoke tests pass (10M malloc/free cycles, pool TLS, real programs)
- Diagnostic mode validated with HAKMEM_TINY_ALLOC_GATE_DIAG=1
- No regressions in existing functionality
- Verified via Task agent (PASS verdict)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 12:06:14 +09:00 |
|