Skip to content

feat/heap pair abi carrier - #4936

Merged
dancinlife merged 7 commits into
mainfrom
feat/heap-pair-abi-carrier
Jul 13, 2026
Merged

dancinlife merged 7 commits into
mainfrom
feat/heap-pair-abi-carrier

Conversation

@dancinlife

Copy link
Copy Markdown
Contributor
  • feat(runtime): HEAP ์ „์šฉ pair-ABI carrier 3์ข… ์‹ ์„ค + array_new ์‹œ๋“œ ๋ฐฐ์„  (byte-neutral)
  • docs(convergence): heap carrier ๋Š” STRONG ์ด์–ด์•ผ ํ•œ๋‹ค โ€” weak ๊ฐ€ arena ๊ฐ€๋กœ์ฑ„๊ธฐ๋ฅผ ํ—ˆ์šฉํ–ˆ๋‹ค

nbcorr-agent and others added 7 commits July 14, 2026 00:58
โ€ฆ-neutral)

๋„ค์ดํ‹ฐ๋ธŒ .s ์‹œ๋“œ๋Š” hexa pair-ABI ๋กœ๋งŒ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, descriptor ๋ฅผ ์žก์„ ์ˆ˜๋‹จ์ด
์•„์˜ˆ ์—†์—ˆ๋‹ค. self/runtime.h ๋ฅผ ์ „์ˆ˜ ์กฐ์‚ฌํ•œ ๊ฒฐ๊ณผ heap ์ „์šฉ pair-ABI carrier ๊ฐ€ ๋ถ€์žฌํ•˜๊ณ ,
์œ ์ผํ•œ ๋ฒ”์šฉ carrier ์ธ hexa_ptr_alloc ์€ ์ด๋ฆ„๊ณผ ๋‹ฌ๋ฆฌ ARENA ๋‹ค:

    _hexa_ptr_alloc:                    # self/native/alloc_syscall_arm64.s:3148
        bl _hexa_arena_alloc            # โ† arena bump-allocator ๋กœ ์œ„์ž„

runtime.a ์•ˆ์— ์ •์˜๊ฐ€ ๋‘˜ ์žˆ๊ณ (runtime.o ์˜ weak malloc vs alloc_syscall_native.o),
๋งํฌ์—์„œ ์ด๊ธฐ๋Š” ์ชฝ์ด ํ›„์ž๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๋ฐฐ์—ด DESCRIPTOR ๋Š” ํ”„๋ ˆ์ž„์„ ํƒˆ์ถœํ•˜๋ฏ€๋กœ arena ์—
์žˆ์œผ๋ฉด rewind ํ›„ ๋‹ค์Œ bump-alloc ์— ์žฌ์‚ฌ์šฉ๋˜์–ด len/cap/items ๊ฐ€ ์กฐ์šฉํžˆ ๋ฎ์–ด์จ์ง„๋‹ค โ€”
C ์›๋ณธ ์ฃผ์„[runtime_core_emit.hexa:2739]์ด ๋ช…์‹œ ๊ธˆ์ง€ํ•˜๋ฉฐ, calloc ์€ ๋ฐ”๋กœ ๊ทธ ๋ฐฉ์–ด์˜€๋‹ค.

  hexa_heap_alloc(size)        malloc
  hexa_heap_zalloc(size)       calloc(1,n) โ€” descriptor ํด๋ž˜์Šค
  hexa_heap_realloc(ptr,size)  realloc โ€” typed-leaf grow ๊ฒฝ๋กœ์šฉ

โ˜… STRONG (non-weak) ์ด ์„ค๊ณ„์˜ ํ•ต์‹ฌ์ด๋‹ค. weak ์˜€๊ธฐ ๋•Œ๋ฌธ์— arena ์‹œ๋“œ๊ฐ€ hexa_ptr_alloc ์„
์†Œ๋ฆฌ ์—†์ด ๊ฐ€๋กœ์ฑ˜๋‹ค. strong ์ด๋ฉด ์–ด๋–ค ๋„ค์ดํ‹ฐ๋ธŒ ์‹œ๋“œ๊ฐ€ ๊ฐ™์€ ์ด๋ฆ„์„ ์ •์˜ํ•˜๋Š” ์ˆœ๊ฐ„
multiple-definition ๊ฒŒ์ดํŠธ๊ฐ€ ๋นŒ๋“œ ์‹œ์ ์— ์‹œ๋„๋Ÿฝ๊ฒŒ ํ„ฐ์ง„๋‹ค โ€” ์กฐ์šฉํ•œ ๊ต์ฒด๋Š” ๋‘ ๋ฒˆ ์—†๋‹ค.

ARRAY_NEW ๊ฐ€๋“œ ๋ฐ”๊นฅ์— emit ํ•œ๋‹ค(์‹œ๋“œ๊ฐ€ ์ผœ์ ธ๋„ carrier ๋Š” ๋‚จ์•„์•ผ ํ•˜๋ฏ€๋กœ). ์ƒ์„ฑ๋œ
runtime_core.c ์—์„œ carrier ๋Š” 2587-2597, ๊ฐ€๋“œ #endif ๋Š” 2582 ๋กœ ํ™•์ธ.

๊ฒ€์ฆ (mini darwin, stage_resolve ํ›„ nm):
    runtime.o: T _hexa_heap_alloc / T _hexa_heap_zalloc / T _hexa_heap_realloc
    weak(W/S/v) 0๊ฑด ยท ๋‹ค๋ฅธ ๋ฉค๋ฒ„์˜ ์ •์˜ 0๊ฑด

BYTE-NEUTRAL โ€” array_new ์˜ .s ์‹œ๋“œ๋Š” main ์— ์—†์œผ๋ฏ€๋กœ(#4932 revert) ARR-NEW ๋Š” C ๊ฒฝ๋กœ๋ฅผ
์œ ์ง€ํ•œ๋‹ค. ์ด PR ์€ substrate + ๋ฐฐ์„ ๊นŒ์ง€์ด๊ณ , flip ์€ regen + byteeq ํ›„ ๋ณ„๋„ ๋ผ์šด๋“œ๋‹ค.

โš ๏ธ ํ•จ๊ป˜ ๋ฐ•์ œํ•˜๋Š” FALSIFIED ๊ฒฐ๊ณผ: "build_aprime ์˜ index 7 out of bounds(len 2) = arena
descriptor ์˜ค์—ผ" ์ด๋ผ๋Š” ๋‚ด ํŒ์ •์€ ํ‹€๋ ธ๋‹ค. ๋‚ด ๋ณ€๊ฒฝ์ด ํ•˜๋‚˜๋„ ์—†๋Š” ์ˆœ์ˆ˜ origin/main
๋Œ€์กฐ๊ตฐ์—์„œ๋„ ๋™์ผํ•˜๊ฒŒ ์žฌํ˜„๋๊ณ , ์ง„์งœ ์›์ธ์€ summer ์˜ HEXA_PREBUILT_RUNTIME ์ด 7/4 ์ž
๋‚ก์€ ~/.hx runtime.a ๋ฅผ ๊ฐ€๋ฆฌํ‚จ ํ™˜๊ฒฝ์˜ค์—ผ์ด์—ˆ๋‹ค(convergence stage-resolve-runtime-a-2
trap#2). arena ๋ผ๋Š” ์‚ฌ์‹ค์€ ์ฐธ์ด์ง€๋งŒ, ๊ทธ๊ฒƒ์ด ๋ˆˆ์•ž ์ฆ์ƒ์˜ ์ธ๊ณผ๋Š” ์•„๋‹ˆ์—ˆ๋‹ค.

state/hexa-own/seed_abi_class_audit.md โ€” ์›Œํฌํ”Œ๋กœ์šฐ wf_5c5b82ee-80b ์ „๋ฌธ(41 ์—์ด์ „ํŠธ ยท
์ ๋Œ€์  ๋ฐ˜์ฆ ํ†ต๊ณผ 33๊ฑด). ๊ฒฐ์ •์  ์‹ ๊ทœ: typed-leaf i64/f64 ๋Š” raw-libc egress ๋ง๊ณ 
SCALAR-ABI ingress/return ๋ฏธ์Šค๋งค์น˜๊ฐ€ ๋”ฐ๋กœ ์žˆ์–ด carrier ์น˜ํ™˜๋งŒ์œผ๋ก  ์•ˆ ๊ณ ์ณ์ง„๋‹ค.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
โ€ฆrrier

# Conflicts:
#	ARCHITECTURE.json
#	ING.jsonl
#	tool/regen_array_new_leaf_native_s.sh
alloc-syscall-arm64-s-1: 'hexa_ptr_alloc = ARENA' ๋Š” ์ฐธ์ด์ง€๋งŒ, ๊ทธ๊ฒƒ์ด build_aprime ์˜
'index 7 out of bounds' ์˜ ์›์ธ์ด๋ผ๋Š” ๋‚ด ํŒ์ •์€ FALSIFIED. ๋‚ด ๋ณ€๊ฒฝ์ด 0 ์ธ ์ˆœ์ˆ˜
origin/main ๋Œ€์กฐ๊ตฐ์—์„œ๋„ ๋™์ผ ์žฌํ˜„๋๊ณ , GitHub ์ƒˆ clone ์—์„œ๋Š” ๊ฐ™์€ main ์ด ์ •์ƒ
๋นŒ๋“œ๋๋‹ค โ€” ์ง„์งœ ์›์ธ์€ ํ’€ ํ˜ธ์ŠคํŠธ์— ๋‚จ์€ stale ์ƒ์„ฑ ์•„ํ‹ฐํŒฉํŠธ์˜€๋‹ค.

build-aprime-sh-3: ๊ทธ stale-์ƒ์„ฑ๋ฌผ ํ•™์Šต. ์ฒ˜์Œ build-aprime-sh-2 ๋กœ ๋„ฃ์—ˆ๋Š”๋ฐ main ์—
๊ฐ™์€ id(์˜ค๋ฅ˜ ํ•„ํ„ฐ ํ•™์Šต)๊ฐ€ ์ด๋ฏธ ์žˆ์–ด union ๋ณ‘ํ•ฉ์—์„œ ์กฐ์šฉํžˆ ๋“œ๋กญ๋๋‹ค โ€” id ์ถฉ๋Œ ์ž์ฒด๊ฐ€
๋˜ ํ•˜๋‚˜์˜ ํ•จ์ •.
์›Œํฌํ”Œ๋กœ์šฐ wf_ba079006-120 (30 ์—์ด์ „ํŠธ ยท ์ ๋Œ€์  ๋ฐ˜์ฆ ํ†ต๊ณผ 23๊ฑด).

๋‚ด ์ „์ œ 4๊ฑด์ด ๋ฐ˜์ฆ๋๋‹ค:
  1. "array_core ๊ฐ€ __hxw_ ๋ธŒ๋ฆฌ์ง€๋ฅผ ์“ด๋‹ค" โ€” FALSE. grep ํžˆํŠธ๊ฐ€ ์ฃผ์„์ด์—ˆ๊ณ , ๊ทธ ์ฃผ์„์€
     ์ •๋ฐ˜๋Œ€๋ฅผ ๋งํ•œ๋‹ค: "no C bridge needed for this nativeโ†’native edge; the __hxseed_
     bridge exists only for C-side callers" [array_core.hexa:54-63].
  2. "๋ธŒ๋ฆฌ์ง€ ๋ฏธ์‚ฌ์šฉ = ์—ญ์‚ฌ์  ๋ˆ„๋ฝ" โ€” FALSE, ๊ตฌ์กฐ์  ๋ถˆ๊ฐ€. #define ์€ runtime_core.c ํ…์ŠคํŠธ๋งŒ
     ๋ฎ๋Š”๋ฐ typed-leaf ์˜ ํ˜ธ์ถœ์ž๋Š” 3์ข…์ด๋‹ค โ€” runtime_core.c ยท gen2 ๊ฐ€ ๋ฑ‰๋Š” user.c ยท
     ๋„ค์ดํ‹ฐ๋ธŒ ๋ฐฑ์—”๋“œ๊ฐ€ ๋ฑ‰๋Š” raw asm call. cpp ๋Š” ๋’ค ๋‘˜์— ๋„๋‹ฌํ•˜์ง€ ๋ชปํ•œ๋‹ค.
  3. "lenโ†’0 ์ด SIGSEGV ๊ทผ์ธ" โ€” FALSE. ๋ฐ๋“œ ์‹ฌ๋ณผ(์‹คํ˜ธ์ถœ์ž 0).
  4. "์ž ๋ณต ๊ฒฐํ•จ" โ€” FALSE. opt-out ๋งŒ ์žˆ๊ณ  ์‹œ๋“œ 9๊ฐœ๊ฐ€ tracked, packed ๊ฒฝ๋กœ๋„ default-ON
     โ†’ ๊นจ์ง„ ์‹œ๋“œ x ๊นจ์ง„ ๋ ˆ์ด์•„์›ƒ์ด ํ˜„์žฌ SHIPPED DEFAULT ๋‹ค.

โ˜… ์‹ ๊ทœ ํ™•์ • โ€” ํด๋ž˜์Šค C (๋””์Šคํฌ๋ฆฝํ„ฐ ๋ ˆ์ด์•„์›ƒ ํ‘œ๋ฅ˜). ์ด๊ฒŒ ์ง„์งœ ๊ทผ์ธ์ด๊ณ  ABI ์ˆ˜์ •์œผ๋กœ๋Š”
์›๋ฆฌ์ ์œผ๋กœ ๋ชป ๊ณ ์นœ๋‹ค:

    C   [runtime_core_emit.hexa:1366-1370]   { int64_t* data@0; int64_t len@8; int64_t cap@16 }  24B
    ์‹œ๋“œ [array_typed_leaf.hexa:65,69-70]     malloc(16) ยท store32(a,8) ยท store32(a,12)          16B

๊ตฌ์กฐ์ฒด๋Š” #3352 ์—์„œ i64 ๋กœ ๋„“์–ด์กŒ๋Š”๋ฐ, ์‹œ๋“œ๋Š” ๊ทธ๋ณด๋‹ค ํ•œ์ฐธ ๋’ค(#4917)์— ์ž‘์„ฑ๋์Œ์—๋„ ์˜›
์น˜์ˆ˜๋ฅผ ์“ด๋‹ค. ์ฝ”๋“œ์  ์€ len ์„ +8 ์—์„œ 64๋น„ํŠธ๋กœ ์ฝ์œผ๋ฏ€๋กœ len=(cap<<32)|len = ๊ฑฐ๋Œ€๊ฐ’์ด ๋˜๊ณ ,
bounds check ๋ฅผ ํ†ต๊ณผํ•ด OOB SIGSEGV. ์—ญ๋ฐฉํ–ฅ(C-mint โ†’ ์‹œ๋“œ push)์€ cap ์„ +12(len ์˜ ์ƒ์œ„
32๋น„ํŠธ)์—์„œ ์ฝ์–ด cap=0 โ†’ realloc(old,0)=free โ†’ UAF.

์ •๋‹ต์ง€๋Š” ๊ฐ™์€ ๋ฆฌํฌ์— ์žˆ๋‹ค โ€” arr_zeros_leaf.hexa:61-63 ์€ store64 @0/@8/@16 ์„ ์“ด๋‹ค.
zeros/array_new ์ด carrier ์น˜ํ™˜๋งŒ์œผ๋กœ ์‚ด์•„๋‚œ ๊ฑด "์Šค์นผ๋ผ ๋ฏธ๋Ÿฌ๊ฐ€ ์—†์–ด์„œ"๋งŒ์ด ์•„๋‹ˆ๋ผ
๋ ˆ์ด์•„์›ƒ๋„ ์ด๋ฏธ ๋งž์•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

๊ถŒ๊ณ ์•ˆ = thunk (์‹œ๋“œ๋ฅผ *_seed ๋กœ rename + all-HexaVal ์‹œ๊ทธ๋‹ˆ์ฒ˜, C ๊ฐ€ ์ •์‹ ์ด๋ฆ„์„ C-ABI
thunk ๋กœ ์†Œ์œ ). 3์ข… ํ˜ธ์ถœ์ž๋ฅผ ์ „๋ถ€ ์ปค๋ฒ„ํ•˜๊ณ  ์ฝ”๋“œ์  /gen2/frozen-seed ํŽธ์ง‘์ด 0์ด๋ฉฐ, rename
์ž์ฒด๊ฐ€ flag-day ๊ฐ€๋“œ๊ฐ€ ๋œ๋‹ค โ€” ๋‚ก์€ runtime.a ๋Š” undefined symbol ๋กœ ์‹œ๋„๋Ÿฝ๊ฒŒ ์ฃฝ์ง€,
์กฐ์šฉํžˆ ๋ ˆ์ง€์Šคํ„ฐ๋ฅผ ์ž˜๋ชป ๋„˜๊ธฐ์ง€ ์•Š๋Š”๋‹ค.

ํด๋ž˜์Šค A(carrier) + B(thunk) + C(๋ ˆ์ด์•„์›ƒ) ์…‹ ๋‹ค ํ•„์ˆ˜๋‹ค. ํ•˜๋‚˜๋งŒ ๊ณ ์ณ์„œ๋Š” SIGSEGV ๊ฐ€
์‚ฌ๋ผ์ง€์ง€ ์•Š๋Š”๋‹ค.

๊ตฌํ˜„-ready ์ŠคํŽ™(E1~E5, ์ „๋ถ€ file:line) = state/hexa-own/typed_leaf_abi_layout_audit.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dancinlife
dancinlife merged commit 77b1ba9 into main Jul 13, 2026
34 of 35 checks passed
dancinlife added a commit that referenced this pull request Jul 15, 2026
โ€ฆrier seeds + own-obj allowlist carrier fix (#4972)

Regen the 3 frozen carrier seeds self/native/array_new_leaf_{x86_64,arm64,
arm64-linux}.s from the #4936-fixed SSOT stdlib/runtime/array_new_leaf.hexa on
the aiden pool + commit. Until now no seed existed (git ls-files empty), so the
.s-seed path in stage_resolve_runtime_a short-circuited and HEXA_RT_ARRAY_NEW_
NATIVE stayed OFF on all 3 targets. With the seeds present, hexa_array_new drops
from the compiled runtime_core.c and routes through the native carrier
(bit-changing).

Seed verify (aiden regen): x86_64 "1/1 T defined, U-floor clean". All 3 are
carrier-only โ€” call/bl hexa_heap_zalloc (the #4930-fix carrier) + bl _hexa_bool
(__hx_payload_eq, expected) + hexa_exit. Zero U-floor breaches (no raw libc
calloc/malloc/free, no boxed slow-call hexa_eq/mul/add_slow). arm64/darwin
cross-assemble WARN-skips on the x86 pool host => real verify = cloud CI 3-target
byteeq.

Allowlist: stage_resolve_runtime_a:686 (the ARR-NEW own-obj path) held a stale
hexa_ptr_alloc entry => it would mis-flag the carrier seed's hexa_heap_zalloc as
_bad and reject it. Fixed to hexa_heap_zalloc, matching the .s-seed path at :722.
:762 is the ARR-ZEROS family (arr_zeros_leaf_native.o) โ€” left untouched (surgical).

Verify: shell syntax check clean (local). Bit-changing => held PR. CI faithful-
nobaseline 3-target byteeq + seed-ABI contract gate + install smoke. Merge only
on all-3-target GREEN; any RED => revert.

no-verify: 36 pre-existing ARCHITECTURE.json ARCH-BIG-CELL/PILED violations on
origin/main, unrelated to this seed-add; CHANGELOG entry staged; ARCHITECTURE
axis-โ‘ก node updates after the CI-verified merge.

Co-authored-by: nbcorr-agent <nbcorr-agent@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant