Skip to content

[pull] master from ruby:master - #1362

Merged
pull[bot] merged 2 commits into
turkdevops:masterfrom
ruby:master
Aug 30, 2026
Merged

[pull] master from ruby:master#1362
pull[bot] merged 2 commits into
turkdevops:masterfrom
ruby:master

Conversation

@pull

@pull pull Bot commented Aug 30, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

ko1 and others added 2 commits August 31, 2026 02:21
transcode_loop() passed the fallback result to rb_econv_insert_output()
as a bare pointer and length.  Nothing roots the string during that call:
args.rep still holds the pre-fallback error-bytes string, and with
clang -O3 the VALUE itself lives in no stack slot the conservative scan
can see -- only the raw data pointer survives in a register, and for an
embedded string that is an interior pointer the scanner rejects.

rb_econv_insert_output() can run a GC: when the fallback string's
encoding differs from the converter's insert encoding it calls
allocate_converted_string(), which opens a fresh econv and allocates the
destination buffer.  The fallback string is then swept mid-call and the
sub-conversion reads its freed bytes.

On an ASAN build this reports use-after-poison at the 1-byte input read
in transcode_restartable0(); CI hit it about once in two hundred runs of
test_fallback_proc, and GC.stress reproduces it in a few hundred
iterations on a clang -O3 ASAN build.  With RB_GC_GUARD the same loop is
clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
rb_econv_insert_output() grew the insertion buffer with

    ruby_xrealloc_sized(*buf_start_p, s, buf_end_p - buf_start_p);

The old-size argument subtracts the two local pointer variables instead
of the pointers they point at, so the allocator's size accounting gets a
small constant rather than the buffer's size.  Present since the sized
variant was introduced; the memory itself was never corrupted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@pull pull Bot locked and limited conversation to collaborators Aug 30, 2026
@pull pull Bot added the ⤵️ pull label Aug 30, 2026
@pull
pull Bot merged commit aa33db6 into turkdevops:master Aug 30, 2026
1 of 3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant