io-console
io-console copied to clipboard
fix segfault on linux with static Ruby 3.2, 3.3, 3.4
Without this patch, IO.console triggers a segfault in statically compiled Ruby on linux. I tested using Docker images ubuntu:latest and homebrew/brew:latest.
Reproduction steps:
0. (optional) Install rv by running curl --proto '=https' --tlsv1.2 -LsSf https://github.com/spinel-coop/rv/releases/download/v0.2.0/rv-installer.sh | sh.
- Install Ruby from rv-ruby releases. With
rvinstalled, you can do this by runningrv ruby install 3.4.7; eval "$(rv shell init bash)". - Check out
io-consolerepository. - Run
bundle install; bundle exec rake compile; bundle exec rake test.
Expected output:
31 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Actual output (without patch):
/src/test/io/console/test_io_console.rb:441: [BUG] Segmentation fault at 0x0000000000000008
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [aarch64-linux]
-- Control frame information -----------------------------------------------
c:0010 p:---- s:0042 e:000041 CFUNC :console
c:0009 p:0072 s:0038 e:000037 BLOCK /src/test/io/console/test_io_console.rb:441 [FINISH]
c:0008 p:---- s:0035 e:000034 CFUNC :class_eval
c:0007 p:0063 s:0031 e:000030 TOP /src/test/io/console/test_io_console.rb:65 [FINISH]
c:0006 p:---- s:0028 e:000027 CFUNC :require
c:0005 p:0054 s:0023 e:000022 BLOCK /home/linuxbrew/.data/rv/rubies/ruby-3.4.7/lib/ruby/3.4.0/bundled_gems.rb:82
c:0004 p:0063 s:0016 e:000015 BLOCK /home/linuxbrew/.gem/ruby/3.4.7/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:21 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC :select
c:0002 p:0012 s:0007 E:001018 EVAL /home/linuxbrew/.gem/ruby/3.4.7/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:6 [FINISH]
c:0001 p:0000 s:0003 E:001600 DUMMY [FINISH]
Actual output (with patch):
Loaded suite /home/linuxbrew/.gem/ruby/3.4.7/gems/rake-13.3.0/lib/rake/rake_test_loader
Started
Finished in 4.224777833 seconds.
-----------------------------------------------------------------------------------------
31 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------
7.34 tests/s, 27.69 assertions/s