An interpreter of object-oriented scripting language
Go to file
Jun Aruga 03fd963481 Disable Fiddle test cases making use of FFI closure.
This commit was cherry-picked from Fedora rawhide
<c2026da175?branch=rawhide>.
In our observation, the libffi issue may happen randomly.

Fiddle::Closure object is making use of FFI closure
from libffi. When such object is created (instantiated) in Ruby,
and then the process forks on an SELinux-enabled system, the memory
will become corrupted. That is usually not a problem until the
The garbage collector sweeps the object and tries to free it, in which case the
Ruby process will fail with signal SIGABRT.

Tests in test/fiddle/test_closure.rb, test/fiddle/test_func.rb,
and test/fiddle/test_function.rb use the `Fiddle::Closure` class
directly and fiddle/test_import.rb use the class indirectly through
`bind_function` method, therefore they are disabled to prevent
introducing the problematic object into the Ruby GC during test suite
execution instead of relying on that fork and subsequent
garbage collection will not happen.

If an FFI closure object is allocated in Ruby
and the `fork` function is used afterward, the memory
pointing to the closure gets corrupted, and if Ruby GC
tries to collect the object in that state, a SIGABRT
error occurs.

The minimal Ruby reproducer for the issue is the following:
~~~
$ cat fiddle_fork.rb
require 'fiddle/closure'
require 'fiddle/struct'

Fiddle::Closure.new(Fiddle::TYPE_VOID, [])

fork { }

GC.start
~~~

We allocate an unused Closure object,
so it is free for the GC to pick up. Before we call `GC.start`
we fork the process as that corrupts the memory.

Running this with ruby-3.1.2-167.fc37.x86_64 on SELinux enabled system:
~~~
$ ruby fiddle_fork.rb
Aborted (core dumped)
~~~

Such issues may appear at random (depending on the use of forking and GC)
in larger applications that use Fiddle::Closure but can be spotted by the
following functions appearing in the coredump backtrace:
~~~
0x00007f6284d3e5b3 in dlfree (mem=<optimized out>) at ../src/dlmalloc.c:4350
0x00007f6284d6d0b1 in dealloc () from /usr/lib64/ruby/fiddle.so
0x00007f6295e432ec in finalize_list () from /lib64/libruby.so.3.1
0x00007f6295e43420 in finalize_deferred.lto_priv () from /lib64/libruby.so.3.1
0x00007f6295e4ff1c in gc_start_internal.lto_priv () from /lib64/libruby.so.3.1
~~~

Possible solutions to prevent Ruby from crashing:
* Do not use Fiddle::Closure.
* Use the Fiddle::Closure object only in isolated subprocess that
  will not fork further.
* Enable static trampolines in libffi as noted in bugzilla comment:
  <https://bugzilla.redhat.com/show_bug.cgi?id=2040380#c9>

See related discussion on
<https://bugzilla.redhat.com/show_bug.cgi?id=2040380>

Ruby upstream ticket:
<https://bugs.ruby-lang.org/issues/18914>

Ruby Fiddle ticket:
<https://github.com/ruby/fiddle/issues/102>

Related: RHEL-5590
2023-12-07 18:28:14 +09:00
.gitignore Upgrade to Ruby 3.0.1. 2021-06-24 21:02:48 +02:00
libruby.stp Initial package 2016-02-17 19:05:04 +01:00
macros.ruby Merge Fedora master. 2018-03-12 17:55:43 +01:00
macros.rubygems Pass ldflags to gem install 2021-07-22 14:18:05 +02:00
operating_system.rb Update to Ruby 2.5.5. 2019-04-18 07:39:17 +02:00
ruby-1.9.3-mkmf-verbose.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.1.0-Enable-configuration-of-archlibdir.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.1.0-Prevent-duplicated-paths-when-empty-version-string-i.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.1.0-always-use-i386.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.1.0-custom-rubygems-location.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.3.0-ruby_version.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.7.0-Initialize-ABRT-hook.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.1.0-Don-t-query-RubyVM-FrozenCore-for-class-path.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.1.1-ossl_ocsp-use-null.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.1.2-ossl-tests-replace-sha1.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.1.3-Fix-for-tzdata-2022g.patch Fix for tzdata-2022g. 2023-10-11 19:16:22 +02:00
ruby-3.2.0-Build-extension-libraries-in-bundled-gems.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.2.0-Detect-compaction-support-during-runtime.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.2.0-define-unsupported-gc-compaction-methods-as-rb_f_notimplement.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-3.2.0-git-2.38.1-fix-rubygems-test.patch Bypass git submodule test failure on Git >= 2.38.1. 2023-10-11 19:15:58 +02:00
ruby-3.3.0-openssl-3.2.0-fips-enable-tests.patch Fix OpenSSL.fips_mode and OpenSSL::PKey.read in OpenSSL 3 FIPS. 2023-10-11 19:17:26 +02:00
ruby-3.3.0-openssl-3.2.0-fips-fix-pkey-dh-require-openssl.patch ssl: use ffdhe2048 from RFC 7919 as the default DH group parameter 2023-10-11 19:20:25 +02:00
ruby-3.3.0-openssl-3.2.0-fips-fix-pkey-read-in-openssl-3.patch Fix OpenSSL.fips_mode and OpenSSL::PKey.read in OpenSSL 3 FIPS. 2023-10-11 19:17:26 +02:00
ruby-3.3.0-openssl-3.2.0-fix-fips-get-set-in-openssl-3.patch Fix OpenSSL.fips_mode and OpenSSL::PKey.read in OpenSSL 3 FIPS. 2023-10-11 19:17:26 +02:00
ruby-bundler-2.4.0-bundle-update-bundler-test-in-ruby.patch Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby-exercise.stp Initial package 2016-02-17 19:05:04 +01:00
ruby-spec-Fix-tests-on-tzdata-2022b.patch Fix tests with Europe/Amsterdam pre-1970 time on tzdata version 2022b. 2023-10-11 19:16:17 +02:00
ruby.rpmlintrc Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
ruby.spec Disable Fiddle test cases making use of FFI closure. 2023-12-07 18:28:14 +09:00
rubygems.attr Merge Fedora master. 2018-03-12 17:55:43 +01:00
rubygems.con Merge Fedora master. 2018-03-12 17:55:43 +01:00
rubygems.prov Update to Ruby 2.6.3 by merging Fedora master branch (commit: 1cc2a49) 2019-06-13 16:56:02 +02:00
rubygems.req Update to Ruby 2.6.3 by merging Fedora master branch (commit: 1cc2a49) 2019-06-13 16:56:02 +02:00
sources Upgrade to Ruby 3.1.2 by merging Fedora Rawhide branch (commit: b7b5473). 2022-06-22 20:36:32 +02:00
test_abrt.rb Initial package 2016-02-17 19:05:04 +01:00
test_openssl_fips.rb Fix OpenSSL.fips_mode and OpenSSL::PKey.read in OpenSSL 3 FIPS. 2023-10-11 19:17:26 +02:00
test_systemtap.rb Fix and enhance systemtap tests 2016-08-03 18:02:20 +02:00