You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Concurrent PTY.spawn crashes the JVM in libfixposix #9977
jruby pty_crash.rb 4 50 crashes on most runs on macOS arm64 (JRuby master, Java 21):
# SIGBUS (0xa) at pc=0x000000018cdd1050
# C [libsystem_platform.dylib+0x3050] __bzero+0x20
C [libfixposix.dylib+0x69d8]
...
j org.jruby.ext.ffi.jffi.DefaultMethodFactory$Signed32Invoker.invoke(...)
The cause is in the bundled ffi-bindings-libfixposix 0.5.1.0. It allocates 32 bytes for lfp_spawn_file_actions_t, but the real struct is 40 bytes on 64-bit platforms. lfp_spawn_file_actions_init writes 8 bytes past the end of the buffer and corrupts the next FFI allocation. The next addclose/adddup2 call then reads a broken struct and crashes.
With SIZEOF = 40 in lib/ruby/stdlib/libfixposix/ffi.rb, the script above passed 15 of 15 runs with 1, 4 and 8 threads. Before the change, about 11 of 15 runs crashed.
Upstream fix: byteit101/subspawn#4. Once a new gem is released, we need to bump ffi-bindings-libfixposix in lib/pom.rb.
There's a second PTY bug in the same gem that shows up alongside this one. PTY.spawn returns the same IO as both reader and writer, so closing the writer closes the reader too:
require"pty"r,w,pid=PTY.spawn("echo","hi")pr.equal?(w)# true on JRuby, false on MRIw.closepr.closed?# true on JRuby, false on MRI
This breaks Rails' bin/ci runner, which closes the writer and then reads the output. It also runs groups in parallel, so it hits the crash above as well.
Activity
sampokuokkanen commentedon Nov 2, 2026
There's a second PTY bug in the same gem that shows up alongside this one.
PTY.spawnreturns the same IO as both reader and writer, so closing the writer closes the reader too:This breaks Rails'
bin/cirunner, which closes the writer and then reads the output. It also runs groups in parallel, so it hits the crash above as well.Fix: byteit101/subspawn#5.