diff --git a/core/front/tiny_unified_cache.c b/core/front/tiny_unified_cache.c index 5fd29ed7..e6029aed 100644 --- a/core/front/tiny_unified_cache.c +++ b/core/front/tiny_unified_cache.c @@ -497,40 +497,6 @@ hak_base_ptr_t unified_cache_refill(int class_idx) { // Freelist pop void* p = m->freelist; - // Validate freelist head before dereferencing (only in debug builds) - #if !HAKMEM_BUILD_RELEASE - do { - SuperSlab* fl_ss = hak_super_lookup(p); - int fl_cap = fl_ss ? ss_slabs_capacity(fl_ss) : 0; - int fl_idx = (fl_ss && fl_ss->magic == SUPERSLAB_MAGIC) ? slab_index_for(fl_ss, p) : -1; - uint8_t fl_cls = (fl_idx >= 0 && fl_idx < fl_cap) ? fl_ss->slabs[fl_idx].class_idx : 0xff; - if (!fl_ss || fl_ss->magic != SUPERSLAB_MAGIC || - fl_idx != tls->slab_idx || fl_ss != tls->ss || - fl_cls != (uint8_t)class_idx) { - static _Atomic uint32_t g_fl_invalid = 0; - uint32_t shot = atomic_fetch_add_explicit(&g_fl_invalid, 1, memory_order_relaxed); - if (shot < 8) { - fprintf(stderr, - "[UNIFIED_FREELIST_INVALID] cls=%d p=%p ss=%p slab=%d meta_used=%u tls_ss=%p tls_slab=%d cls_meta=%u\n", - class_idx, - p, - (void*)fl_ss, - fl_idx, - m->used, - (void*)tls->ss, - tls->slab_idx, - (unsigned)fl_cls); - } - // Drop invalid freelist to avoid SEGV and force slow refill - m->freelist = NULL; - p = NULL; - } - } while (0); - #endif - if (!p) { - break; - } - void* next_node = tiny_next_read(class_idx, p); // ROOT CAUSE FIX: Write header BEFORE exposing block (but AFTER reading next) diff --git a/core/front/tiny_unified_cache.h b/core/front/tiny_unified_cache.h index 1b0b05e5..2c53cf89 100644 --- a/core/front/tiny_unified_cache.h +++ b/core/front/tiny_unified_cache.h @@ -57,7 +57,7 @@ static inline int unified_cache_measure_check(void) { // Unified Cache Structure (per class) // ============================================================================ -typedef struct { +typedef struct __attribute__((aligned(64))) { // slots は BASE ポインタ群を保持する(ユーザポインタではない)。 // API では hak_base_ptr_t で型安全に扱い、内部表現は void* のまま。 void** slots; // Dynamic array of BASE pointers (allocated at init)