Project

General

Profile

Actions

Bug #22073

closed

Ruby 3.4.9 segfaults when loading native default gems compiled on Ubuntu 26.04 (GCC 15.2); Ruby 4.0.3 unaffected on same system

Bug #22073: Ruby 3.4.9 segfaults when loading native default gems compiled on Ubuntu 26.04 (GCC 15.2); Ruby 4.0.3 unaffected on same system

Added by taq (Eustaquio Rangel) about 9 hours ago. Updated about 2 hours ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
[ruby-core:125534]

Description

Hello, I'm reporting a reproducible issue on Ruby 3.4.9 on a freshly upgraded Ubuntu 26.04 LTS. Please let me know if you'd prefer this as a comment on #21655 instead.

On Ubuntu 26.04 LTS, Ruby 3.4.9 produces unusable binaries when compiling current versions of native default gems (prism, cgi, date, io-console, rbs, and likely others).
The versions of these gems that ship with the Ruby tarball work fine, but as soon as bundle install (or any gem install) compiles a newer version of them in the local environment, loading those gems segfaults or bus-errors immediately.
Ruby 4.0.3 on the same machine, same toolchain, same Ubuntu installation does not exhibit this problem.

My environment:

OS: Ubuntu 26.04 LTS (Resolute Raccoon), upgraded today
Kernel: 7.0.0-15-generic
glibc: ldd (Ubuntu GLIBC 2.43-2ubuntu2) 2.43
System GCC: gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0 (default is GCC 15.2 on this release; GCC 14 also tested via apt install gcc-14)
Ruby: ruby 3.4.9 (2026-03-11 revision 76cca827ab) +YJIT +PRISM [x86_64-linux]

Reproduced with both RVM and rbenv (independent installations)

  1. Install Ruby 3.4.9 on Ubuntu 26.04. irb works.
  2. gem install bundler && bundle install in any project with a non-trivial Gemfile (e.g. Rails 8). Among other things, this installs newer versions of default gems: prism 1.9.0, cgi 0.5.1, date 3.5.1, io-console 0.8.2, etc.
  3. Run irb (or any Ruby that loads one of those gems). Segfault or bus error on loading the native .so.

The crashing extension varies depending on load order, but I've reproduced it in prism.so, cgi/escape.so, date_core.so, io/console.so, and rbs_extension.so.
Removing the newer gem from the gemset (e.g. rm -rf ~/.rvm/gems/ruby-3.4.9/gems/prism-1.9.0) causes Ruby to fall back to the older version that ships with the Ruby tarball (prism 1.5.2), which works — until the next crash on another default gem.

Ruby 4.0.3 installed via the same RVM, on the same Ubuntu 26.04 system, runs a non-trivial Rails 8 application with bundle install and bundle exec working without any crashes. This suggests the fix (or whatever change avoids the issue) is on master/4.0 and was not backported to the 3.4 branch.

Workarounds attempted (none successful):

  1. rvm get stable to install all current Ruby build dependencies (including libncurses5-dev which was initially missing). Ruby itself rebuilt; gems still crash.
  2. Rebuilding Ruby with CFLAGS="-fno-ipa-modref" per #21655. RbConfig::CONFIG["CFLAGS"] confirms the flag is in the build. Gems still crash. (Note: I have not verified whether the flag is propagated to the gem build via mkmf.)
  3. Rebuilding Ruby with CC=gcc-14 CXX=g++-14 (GCC 14 is available in default 26.04 repositories). Gems still crash.
  4. Reinstalling Ruby 3.4.9 via rbenv (independent of RVM) and reproducing from scratch. Same crash.

Happy to provide additional information — debug build, full gdb backtrace, build logs, etc. Just let me know what would be most useful.
Thank you.

Updated by taq (Eustaquio Rangel) about 9 hours ago Actions #1 [ruby-core:125535]

Uh-oh ... tried to install 4.0.4 and ... same behaviour.

Updated by taq (Eustaquio Rangel) about 9 hours ago Actions #2 [ruby-core:125536]

Check this out:

`❯ rvm use ruby-4.0.4
Using /home/taq/.rvm/gems/ruby-4.0.4

❯ irb
4.0.4 :001 > exit

❯ gem install bundler
Fetching bundler-4.0.11.gem
Successfully installed bundler-4.0.11
Parsing documentation for bundler-4.0.11
Installing ri documentation for bundler-4.0.11
Done installing documentation for bundler after 0 seconds
1 gem installed

❯ irb
4.0.4 :001 > exit

❯ gem install prism
Fetching prism-1.9.0.gem
Building native extensions. This could take a while...
Successfully installed prism-1.9.0
Parsing documentation for prism-1.9.0
Installing ri documentation for prism-1.9.0
Done installing documentation for prism after 4 seconds
1 gem installed

❯ irb
/home/taq/.rvm/gems/ruby-4.0.4/gems/prism-1.9.0/lib/prism/prism.so: [BUG] Segmentation fault at 0x0000000000000008
ruby 4.0.4 (2026-05-12 revision b89eb1bcbf) +YJIT +PRISM [x86_64-linux]`

Updated by taq (Eustaquio Rangel) about 7 hours ago Actions #3 [ruby-core:125537]

I had an idea here and installed a fresh Ubuntu 26.04 copy on a new VM, and it worked!

taq@taq2604:~$ rvm use 3.4.9
Using /home/taq/.rvm/gems/ruby-3.4.9

taq@taq2604:~$ ruby -v
ruby 3.4.9 (2026-03-11 revision 76cca827ab) +PRISM [x86_64-linux]

taq@taq2604:~$ irb
3.4.9 :001 > exit

taq@taq2604:~$ gem install prism
Fetching prism-1.9.0.gem
Building native extensions. This could take a while...
Successfully installed prism-1.9.0
1 gem installed

taq@taq2604:~$ irb
3.4.9 :001 > exit

taq@taq2604:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 26.04 LTS
Release:	26.04
Codename:	resolute

Before reinstalling it again I'll try to implode RVM (but, as mentioned, I tried rbenv etc) and see if works. If don't, maybe it's some package lost on the upgrade.

Updated by taq (Eustaquio Rangel) about 6 hours ago Actions #4 [ruby-core:125538]

Seems the Ubuntu build system is broken after upgrading. I tried to compile Neovim from sources and it segfaults too. Testing on the fresh VM, it works.

Updated by taq (Eustaquio Rangel) about 4 hours ago Actions #5 [ruby-core:125539]

Update / Resolution:

After further investigation, I was able to identify the root cause. The issue was not with Ruby 3.4.9, GCC 15.2, or Ubuntu 26.04 itself.

My home directory is mounted with eCryptfs (Ubuntu's home directory encryption).

The RVM installation resides in ~/.rvm/, which is inside the encrypted filesystem. When compiling native gems, mkmf writes the .so file and immediately loads it — and eCryptfs apparently does not guarantee that a freshly written binary is immediately available for execution, causing segfaults at load time.

Confirmation: reinstalling RVM in /opt/rvm (outside the encrypted filesystem) and reinstalling Ruby 3.4.9 there resolved all segfaults completely. The same bundle install that previously crashed now works without issues.
The same root cause also explained segfaults I was seeing when building Neovim from source in my home directory — it compiles LuaJIT in .deps/ and immediately executes it during the build process. Building in /opt worked fine.
Ruby 3.4.9, GCC 15.2, and Ubuntu 26.04 are not at fault.

I apologize for the noise. Hopefully this helps someone else who hits the same issue with eCryptfs and native extensions.

Updated by alanwu (Alan Wu) about 2 hours ago Actions #6 [ruby-core:125541]

  • Status changed from Open to Third Party's Issue

Thanks for reporting back!

Actions

Also available in: PDF Atom