Skip to content

Conversation

@koh-sh
Copy link
Contributor

@koh-sh koh-sh commented Aug 9, 2025

Summary

Fixes segmentation fault when calling seek with SEEK_END on null device StringIO created by
StringIO.new(nil).

How to Reproduce

ruby -e "require 'stringio'; StringIO.new(nil).seek(0, IO::SEEK_END)"

I tested with below versions.

[koh@Kohs-MacBook-Pro] ~
% ruby -v;gem info stringio;sw_vers
ruby 3.4.5 (2025-07-16 revision 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] ~
% 

@kou
Copy link
Member

kou commented Aug 9, 2025

Good catch.

Could you also try fixing the JRuby implementation?

@koh-sh
Copy link
Contributor Author

koh-sh commented Aug 9, 2025

@kou

Thank you for the suggestion.
The same fix has been applied to the JRuby implementation too.
ac0ad23

@kou kou merged commit 9399747 into ruby:master Aug 9, 2025
51 checks passed
@kou
Copy link
Member

kou commented Aug 9, 2025

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
@nobu nobu mentioned this pull request Aug 9, 2025
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.

2 participants