- Feature: Added HAKMEM_TINY_HEADERLESS toggle (A/B testing) - Feature: Implemented Headerless layout logic (Offset=0) - Refactor: Centralized layout definitions in tiny_layout_box.h - Refactor: Abstracted pointer arithmetic in free path via ptr_conversion_box.h - Verification: sh8bench passes in Headerless mode (No TLS_SLL_HDR_RESET) - Known Issue: Regression in Phase 1 mode due to blind pointer conversion logic
64 lines
2.6 KiB
Markdown
64 lines
2.6 KiB
Markdown
# SEGV 調査報告書 (Phase 2 Implementaton)
|
||
|
||
**ステータス**: Phase 2 実装完了後の初期テストで混合的な結果が発生。
|
||
|
||
## 🚨 現状サマリー
|
||
|
||
| モード | フラグ | sh8bench (目標) | cfrac (回帰) | larson (回帰) |
|
||
|---|---|---|---|---|
|
||
| **Headerless** | `HAKMEM_TINY_HEADERLESS=1` | ✅ **PASS** (Resetなし) | ❌ SEGV | 未確認 |
|
||
| **Phase 1 互換** | `HAKMEM_TINY_HEADERLESS=0` | ❌ SEGV (Regression) | 未確認 | 未確認 |
|
||
|
||
## 🔍 原因分析 (仮説)
|
||
|
||
### 1. `ptr_user_to_base_blind` の実装ミス (Phase 1 互換モード)
|
||
|
||
`core/box/ptr_conversion_box.h` における実装を確認:
|
||
|
||
```c
|
||
static inline void* ptr_user_to_base_blind(void* user_ptr) {
|
||
if (user_ptr == NULL) return NULL;
|
||
|
||
#if HAKMEM_TINY_HEADERLESS
|
||
// Headerless: base = user
|
||
return user_ptr;
|
||
#else
|
||
// Phase 1: All classes have 1 byte header -> base = user - 1
|
||
// ⚠️ ここが間違い!
|
||
return (void*)((uint8_t*)user_ptr - 1);
|
||
#endif
|
||
}
|
||
```
|
||
|
||
**問題点**:
|
||
Phase 1 (`HAKMEM_TINY_HEADERLESS=0`) において、`tiny_layout_box.h` の定義では:
|
||
- Class 1-6: Offset = 1
|
||
- **Class 0, 7: Offset = 0**
|
||
|
||
しかし、`ptr_user_to_base_blind` は**無条件に -1 している**ため、Class 0 (8B) と Class 7 (2048B) のポインタが 1バイトずれます。これが `sh8bench` (Class 1使用) 以外のワークロードや、特定の境界条件で SEGV を引き起こしている可能性が高いです。
|
||
|
||
### 2. Headerless モードでの cfrac SEGV
|
||
|
||
Headerless モードでは Offset=0 (Identity) なので上記の問題は発生しません。
|
||
しかし `cfrac` が落ちる理由として:
|
||
- `front_gate_classifier.c` がヘッダー(存在しない)を読もうとしている?
|
||
- `free_tiny_fast` がヘッダーチェックで誤判定している?
|
||
- `tiny_region_id_read_header` が無効化されているが、呼び出し元が -1 を期待していない?
|
||
|
||
## 🛠️ 修正方針
|
||
|
||
### Phase 1 互換モードの修正
|
||
`ptr_user_to_base_blind` は `class_idx` なしでは正確な Base を特定できません(Class 0/7 かどうか判別できないため)。
|
||
したがって、`free()` パスでは **SuperSlab から class_idx を引くか、何らかの方法で Offset を特定する必要があります**。
|
||
|
||
### Headerless モードの修正
|
||
`cfrac` の SEGV 箇所を特定し、ヘッダーアクセスが残存している箇所を特定・排除します。
|
||
|
||
---
|
||
|
||
## 次のステップ
|
||
|
||
1. `ptr_user_to_base_blind` のロジック見直し(blind変換は危険すぎる可能性)
|
||
2. cfrac のバックトレース取得
|
||
3. 修正パッチの適用
|