Repository navigation
Put read_path_at / read_path_whole StrBufs in regions (main's strbuf gate) - #409
Conversation
#373 added read_path_whole and read_path_at, each building its result in a StrBuf made outside every region block. It was branched before #393 added tools/strbuf_region_check.py, so after both merged the gate failed on main (build-linux, corpus, and run_corpus.sh locally): m_state.mere:4832 (read_path_whole) m_state.mere:4855 (read_path_at) Each read loop now runs in a region of its own (READ_PATH_WHOLE_B, READ_PATH_AT_B), which hands out only the text. The open, the seek and their error answers stay outside the region and are unchanged, and the descriptor is closed inside it as before. A File.read of 1 MiB from /dev/urandom, or of a pipe through /dev/fd/N, no longer keeps a buffer of that size for the rest of the run.
284km
left a comment
There was a problem hiding this comment.
Post-merge review of exact head e78e9658668673379d9e1ad5d9d7f4478a0e3b0a against the base fetched at review start 5b815b660e9ea2ca28382da1ab15efa1db9c1a70: no actionable findings. The PR was merged externally during validation; resulting main 9d1c0f32cad65ca8df45da2466beb27dcd35e015 has the exact tested head tree (fb2fed33). I did not initiate the merge.
The region boundaries preserve the existing open/seek/close/error order. Generated C copies each returned string into the enclosing region before releasing the temporary region, and constructs the bounded-read pair afterward. I also checked that the shared tcp_arena backing storage survives and that its cached boxed offset is copied into the map's region.
Independent validation on Darwin arm64:
- Fresh ordinary O2 builds of base and head, using a freshly built pinned compiler
9dec2ff687a08433247dbdb7729bc19c8522e538and mgz661a01d8; clean reference Ruby 4.0.10 selected throughtools/ref_ruby.sh. - Corpus 838 plus an additional probe for chunk boundaries, retained binary strings after repeated reads/GC, devices, empty/missing/unreadable paths, and pipe reads/refused seeks: all 32 exit/stdout/stderr comparisons match Ruby across both trees, evaluator/strict VM, Hash index ON/OFF, and normal GC/GC20.
- StrBuf source and emitted-C gate passes on head; base reproduces both recorded helper violations. GC roots, dead/duplicate definitions, name lengths, method writes, record hygiene, bracket depth, and diff checks pass.
- Separate 1-round / 5-round processes measured with
/usr/bin/time -l, maximum RSS in KiB:
| Workload per round | Base, 1 / 5 rounds | Head, 1 / 5 rounds |
|---|---|---|
50 reads of 1 MiB from /dev/urandom |
164576 / 370256 | 124000 / 124416 |
| 500 reads of 60 KB pipes | 136448 / 275248 | 109664 / 137520 |
All eight resource runs returned the expected bytes/sizes. Pipe growth remains; these local measurements do not establish elimination of every memory issue or Linux resource acceptance. RSS measurement required an approved sandbox exception because the sandbox blocked time's sysctl; that restriction was not a runtime failure.
The previous main CI's 25 jobs were inspected: 22 succeeded, two failed at this StrBuf gate, one was skipped. Post-merge main CI 46342657606 remains incomplete: the harness and plan passed, Linux is running, and macOS/reference jobs are queued, with downstream coverage unfinished. The original PR core run was cancelled after the merge. I did not rerun the full corpus or whole upstream suites, and do not claim hosted acceptance or clearance of the recorded merge holds. Other open PRs are drafts; no further merge was attempted.
The failure
Since #373 merged, main's
build-linuxandcorpusjobs stop at the source gate, andrun_corpus.shstops there locally before running any program:(the source half of the check names
m_state.mere:4832 (read_path_whole)andm_state.mere:4855 (read_path_at)).Cause
#373 added
read_path_wholeandread_path_atinm_state.mere, each building its result in a StrBuf made outside everyregionblock. It was branched before #393 addedtools/strbuf_region_check.py, so each PR passed on its own and main failed once both were in.The change
Each function's read loop now runs in a region of its own, following #393's pattern (
READ_PATH_WHOLE_B,READ_PATH_AT_B); the region hands out only the text. Nothing is added toALLOWED.read_path_atstill answers(errno or 13, "")when the open fails and(-1, "")when the seek is refused, after closing the descriptor;read_path_wholestill falls back toread_filewhen the open fails.fd_closerun inside the region in the same order as before; the emitted C copies the string out of the region before it is released.read_path_at's pair is made outside the region from the copied text.tcp_arena's first call may now happen inside a region;map_setcopies the stored value into the map's own region, so the scratch pointer outlives the block.Local results (macOS arm64, Mere at the CI
MERE_REF9dec2ff6,tools/build.sh-O2)python3 tools/strbuf_region_check.py: passes, with the mr.c half ("mr.c: 3 functions with one in the default region, all allowed").sh run_corpus.sh --both: 1039/1039 corpus programs match ruby, with the hash index ON and OFF (all source gates included).sh tools/iseq/vm_corpus.sh -j 3: 1039 programs, 1039 on the VM, 0 fell back, 0 FAIL.MERE_RUBY_GC_STRESS=20.File.readwith a length on an unreadable file, a missing file, a length of 0, an offset past the end,/dev/urandomwith offset 2**40,/dev/zero, a pipe through/dev/fd/Nwith and without a length and with an offset (ESPIPE)): identical to ruby on both engines and to main's build.GC.start:File.read(path, 4, 0)50,000 a roundFile.read("/dev/urandom", 16)50,000 a roundFile.read("/dev/urandom", 1 << 20)50 a roundFile.read("/dev/fd/N")500 a roundThe pipe row still rises by about 1 MB a round on this branch, but the same loop without
File.read(IO.pipe,w.write,r.read) rises the same way on both builds (90016 → 93872 on main, 89952 → 94048 here), so that growth is not in these two functions.🤖 Generated with Claude Code