Files
hakmem/core/box/front_gate_box.h
Moe Charm (CI) abb7512f1e Fix critical type safety bug: enforce hak_base_ptr_t in tiny_alloc_fast_push
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>
2025-12-04 04:58:22 +09:00

17 lines
624 B
C

// front_gate_box.h - Front Gate Box (SFC/SLL priority and helpers)
#pragma once
#include <stddef.h>
#include "hakmem_tiny.h"
// Try to pop a block from Front Gate (SFC -> TLS SLL).
// Returns 1 on success and stores the pointer to *out_ptr, else 0.
int front_gate_try_pop(int class_idx, void** out_ptr);
// After backend refill, optionally cascade some blocks SLL -> SFC.
// Intended to keep SFC warm without extra backend calls.
void front_gate_after_refill(int class_idx, int refilled_count);
// Push a block to TLS freelist (SLL). Used by free fast path.
void front_gate_push_tls(int class_idx, hak_base_ptr_t ptr);