From: "ErezGeva2@... (Erez Geva) via ruby-core" <ruby-core@...> Date: 2024-08-11T09:59:09+00:00 Subject: [ruby-core:118832] [Ruby master Bug#20666] Segmentation fault instead of LoadError exception Issue #20666 has been updated by ErezGeva2@gmail.com (Erez Geva). File small_ruby_test_log.zip added Did some minimising. # Three sources: ## `extconf.rb` > require 'mkmf' > create_header > create_makefile 'good' ## `good.cpp` > #include <ruby.h> > extern "C" void Init_good(void) {rb_require("bad");} ## `load.rb` > begin > require 'good' > rescue LoadError => e > print "#{e.to_s}\n" > end # Result on Linux `$ ruby extconf.rb; make; ruby -I. load.rb; echo $?` > creating extconf.h > creating Makefile > compiling good.cpp > linking shared-object good.so > cannot load such file -- bad > 0 We catch the `LoadError` exception and exit gracefully. # Result on Windows Using the same Ruby 3.1.6 and Ruby 3.2.5 with GCC MinGW-W64 ucrt64 We run the same test in `small ruby test`. We get `Segmentation fault`. Attach is the log files of the `small ruby test`. You can find the tests on github: https://github.com/erezgeva/swig/actions/runs/10338780577 ---------------------------------------- Bug #20666: Segmentation fault instead of LoadError exception https://bugs.ruby-lang.org/issues/20666#change-109396 * Author: ErezGeva2@gmail.com (Erez Geva) * Status: Open * ruby -v: ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x64-mingw-ucrt] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Using ruby -v ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x64-mingw-ucrt] >From [GitHub windows 2022](https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md ) We run the SWIG test: [import_fragments](https://github.com/swig/swig/blob/master/Examples/test-suite/ruby/import_fragments_runme.rb) The test try to load a broken library, which should rise a `LoadError`. begin require 'import_fragments' rescue LoadError => e # due to missing import_fragments_a exception_file = e.respond_to?(:path) ? e.path : e.to_s.sub(/.* -- /, '') end Instead `LoadError` exception we get `Segmentation fault`: <internal:C:/hostedtoolcache/windows/Ruby/3.2.5/x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:151: [BUG] Segmentation fault ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x64-mingw-ucrt] -- Control frame information ----------------------------------------------- c:0004 p:0018 s:0028 e:000025 RESCUE <internal:C:/hostedtoolcache/windows/Ruby/3.2.5/x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:151 c:0003 p:0275 s:0022 e:000021 METHOD <internal:C:/hostedtoolcache/windows/Ruby/3.2.5/x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:40 c:0002 p:0011 s:0007 E:0004e8 EVAL ./import_fragments_runme.rb:13 [FINISH] c:0001 p:0000 s:0003 E:0006e0 DUMMY [FINISH] ---Files-------------------------------- source.zip (20.2 KB) small_ruby_test_log.zip (6.09 KB) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/