Root cause: Functions tiny_alloc_fast_push() and front_gate_push_tls() accepted void* instead of hak_base_ptr_t, allowing implicit conversion of USER pointers to BASE pointers. This caused memory corruption in TLS SLL operations. Changes: - core/tiny_alloc_fast.inc.h:879 - Change parameter type to hak_base_ptr_t - core/tiny_alloc_fast_push.c:17 - Change parameter type to hak_base_ptr_t - core/tiny_free_fast.inc.h:46 - Update extern declaration - core/box/front_gate_box.h:15 - Change parameter type to hak_base_ptr_t - core/box/front_gate_box.c:68 - Change parameter type to hak_base_ptr_t - core/box/tls_sll_box.h - Add misaligned next pointer guard and enhanced logging Result: Zero misaligned next pointer detections in tests. Corruption eliminated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
975 B
C
28 lines
975 B
C
// tiny_alloc_fast_push.c - Out-of-line helper for Box 5/6
|
|
// Purpose:
|
|
// Provide a non-inline definition of tiny_alloc_fast_push() for TUs
|
|
// that include tiny_free_fast_v2.inc.h / hak_free_api.inc.h without
|
|
// also including tiny_alloc_fast.inc.h.
|
|
//
|
|
// Box Theory:
|
|
// - Box 5 (Alloc Fast Path) owns the TLS freelist push semantics.
|
|
// - This file is a thin proxy that reuses existing Box APIs
|
|
// (front_gate_push_tls or tls_sll_push) without duplicating policy.
|
|
|
|
#include <stdint.h>
|
|
#include "hakmem_tiny_config.h"
|
|
#include "box/tls_sll_box.h"
|
|
#include "box/front_gate_box.h"
|
|
|
|
void tiny_alloc_fast_push(int class_idx, hak_base_ptr_t ptr) {
|
|
#ifdef HAKMEM_TINY_FRONT_GATE_BOX
|
|
// When FrontGate Box is enabled, delegate to its TLS push helper.
|
|
front_gate_push_tls(class_idx, ptr);
|
|
#else
|
|
// Default: push directly into TLS SLL with "unbounded" capacity.
|
|
uint32_t capacity = UINT32_MAX;
|
|
(void)tls_sll_push(class_idx, ptr, capacity);
|
|
#endif
|
|
}
|
|
|