Skip to content

Ensure the initial string has correct size#9373

Merged
headius merged 1 commit into
jruby:jruby-10.0from
headius:dynamic_string_indy_sizing
Apr 14, 2026
Merged

Ensure the initial string has correct size#9373
headius merged 1 commit into
jruby:jruby-10.0from
headius:dynamic_string_indy_sizing

Conversation

@headius

@headius headius commented Apr 10, 2026

Copy link
Copy Markdown
Member

The initial string here was created using the size estimate from the IR, but that number does not appear to include the first string used to start the buffer. The logic then incorrectly allocated an array of initial size but used the first string's real size as the size for the ByteList. In the case reported, this resulted in the buffer ByteList containing a shorter array than the size it claimed, eventually leading to an ArrayIndexOutOfBounds error.

The change here fixes the incorrect use of the first string's real size with the buffer as well as always ensuring the buffer has enough room for that initial string plus the estimate. We will want to review how these estimates are being calculated, since it seems there's some confusion as to what is included.

Fixes #9372

See also #9046

The initial string here was created using the size estimate from
the IR, but that number does not appear to include the first
string used to start the buffer. The logic then incorrectly
allocated an array of initial size but used the first string's
real size as the size for the ByteList. In the case reported, this
resulted in the buffer ByteList containing a shorter array than the
size it claimed, eventually leading to an ArrayIndexOutOfBounds
error.

The change here fixes the incorrect use of the first string's real
size with the buffer as well as always ensuring the buffer has
enough room for that initial string plus the estimate. We will
want to review how these estimates are being calculated, since it
seems there's some confusion as to what is included.

Fixes jruby#9372

See also jruby#9046
@headius headius added this to the JRuby 10.0.6.0 milestone Apr 10, 2026
@headius headius linked an issue Apr 10, 2026 that may be closed by this pull request
@headius
headius merged commit c8feff9 into jruby:jruby-10.0 Apr 14, 2026
204 of 207 checks passed
@headius
headius deleted the dynamic_string_indy_sizing branch April 14, 2026 19:30
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.

Crash when AOT compiling rubocop-ast sources

1 participant