Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Dec 18, 2025

When creating an FString for the first time, we should never trust that the incoming byte[] or ByteList are now ours to own. The caller might still have a reference to them that they continue to modify, resulting in a zombie FString that can't be found or that has incorrect contents.

This came up while trying to implement the "fake string" optimization for uncached headers in puma/puma#3838. Holding a reference to a RubyString and its ByteList that could be updated in-place and then used to caches new headers led to those cached FStrings being modified directly.

When creating an FString for the first time, we should never trust
that the incoming byte[] or ByteList are now ours to own. The
caller might still have a reference to them that they continue to
modify, resulting in a zombie FString that can't be found or that
has incorrect contents.

This came up while trying to implement the "fake string"
optimization for uncached headers in puma/puma#3838. Holding a
reference to a RubyString and its ByteList that could be updated
in-place and then used to caches new headers led to those cached
FStrings being modified directly.
@headius headius added this to the JRuby 10.0.3.0 milestone Dec 18, 2025
@headius headius merged commit 3e36f8d into jruby:master Dec 18, 2025
77 checks passed
@headius headius deleted the defensive_fstring branch December 18, 2025 19:54
headius added a commit that referenced this pull request Dec 18, 2025
@headius
Copy link
Member Author

headius commented Dec 18, 2025

Pushed a test after merge in 1cb0236

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