fix: prevent segfault in StringIO#seek with SEEK_END on null device#137
Merged
kou merged 2 commits intoruby:masterfrom Aug 9, 2025
Merged
fix: prevent segfault in StringIO#seek with SEEK_END on null device#137kou merged 2 commits intoruby:masterfrom
kou merged 2 commits intoruby:masterfrom
Conversation
Member
|
Good catch. Could you also try fixing the JRuby implementation? |
…ull device (JRuby)
Contributor
Author
Member
|
Thanks. |
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Aug 9, 2025
on null device (ruby/stringio#137) Fixes segmentation fault when calling `seek` with `SEEK_END` on null device StringIO created by `StringIO.new(nil)`. ```bash ruby -e "require 'stringio'; StringIO.new(nil).seek(0, IO::SEEK_END)" ``` I tested with below versions. ```bash [koh@Kohs-MacBook-Pro] ~ % ruby -v;gem info stringio;sw_vers ruby 3.4.5 (2025-07-16 revision ruby/stringio@20cda200d3) +PRISM [arm64-darwin24] *** LOCAL GEMS *** stringio (3.1.2) Authors: Nobu Nakada, Charles Oliver Nutter Homepage: https://github.com/ruby/stringio Licenses: Ruby, BSD-2-Clause Installed at (default): /Users/koh/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0 Pseudo IO on String ProductName: macOS ProductVersion: 15.5 BuildVersion: 24F74 [koh@Kohs-MacBook-Pro] ~ % ``` ruby/stringio@9399747bf9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes segmentation fault when calling
seekwithSEEK_ENDon null device StringIO created byStringIO.new(nil).How to Reproduce
ruby -e "require 'stringio'; StringIO.new(nil).seek(0, IO::SEEK_END)"I tested with below versions.