Files
hakmem/docs/archive/BUG_FLOW_DIAGRAM.md
Moe Charm (CI) a9ddb52ad4 ENV cleanup: Remove BG/HotMag vars & guard fprintf (Larson 52.3M ops/s)
Phase 1 完了:環境変数整理 + fprintf デバッグガード

ENV変数削除(BG/HotMag系):
- core/hakmem_tiny_init.inc: HotMag ENV 削除 (~131 lines)
- core/hakmem_tiny_bg_spill.c: BG spill ENV 削除
- core/tiny_refill.h: BG remote 固定値化
- core/hakmem_tiny_slow.inc: BG refs 削除

fprintf Debug Guards (#if !HAKMEM_BUILD_RELEASE):
- core/hakmem_shared_pool.c: Lock stats (~18 fprintf)
- core/page_arena.c: Init/Shutdown/Stats (~27 fprintf)
- core/hakmem.c: SIGSEGV init message

ドキュメント整理:
- 328 markdown files 削除(旧レポート・重複docs)

性能確認:
- Larson: 52.35M ops/s (前回52.8M、安定動作)
- ENV整理による機能影響なし
- Debug出力は一部残存(次phase で対応)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 14:45:26 +09:00

1.1 KiB

Bug Flow Diagram: P0 Batch Refill Active Counter Underflow

Legend

  • Box 2: Remote Queue (push/drain)
  • Box 3: Ownership (owner_tid)
  • Box 4: Publish/Adopt + Refill boundary (superslab_refill)

Flow (before fix)

free(ptr)
  -> Box 2 remote_push (cross-thread)
      - active-- (on free)           [OK]
      - goes into SS freelist        [no active change]

refill (P0 batch)
  -> trc_pop_from_freelist(meta, want)
      - splice to TLS SLL            [OK]
      - MISSING: active += taken     [BUG]

alloc() uses SLL

free(ptr) (again)
  -> active-- (but not incremented before) → double-decrement
  -> active underflow → OOM perceived
  -> superslab_refill returns NULL → crash path (free(): invalid pointer)

After fix

refill (P0 batch)
  -> trc_pop_from_freelist(...)
      - splice to TLS SLL
      - active += from_freelist      [FIX]
  -> trc_linear_carve(...)
      - active += batch              [asserted]

Verification Hooks

  • One-shot OOM prints from superslab_refill
  • Optional: HAKMEM_TINY_DEBUG_REMOTE_GUARD=1 and HAKMEM_TINY_TRACE_RING=1