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
TracePoint does not support fiber_switch (Ruby 2.3+ compatibility) #9600
$ mise x ruby@jruby -- ruby -v jruby 10.1.0.0 (4.0.0) 2026-04-20 32f988b78c OpenJDK 64-Bit Server VM 26.0.2+10-55 on 26.0.2+10-55 +indy +jit [arm64-darwin]
$ uname -aDarwin Konstantins-MBP.localdomain 25.5.0 Darwin Kernel Version 25.5.0: Tue Jun 9 22:28:34 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T6041 arm64
No other dependencies are needed to run into this issue.
I found this by tracing which thread a fiber scheduler fiber belongs to.
Expected Behavior
Should trace fiber_switch events (introduced in Ruby 2.3.0)
ArgumentError: unknown event: fiber_switch
initialize at org/jruby/ext/tracepoint/TracePoint.java:65
new at org/jruby/RubyClass.java:1058
trace at org/jruby/ext/tracepoint/TracePoint.java:282
<main> at play/trace.rb:3
Right you are. This does not seem to have coverage in rubyspec but we do have a related test from the CRuby suite excluded currently. I would not expect it to be difficult to implement.
FWIW, I'm not 100% sure the current patch fits my use case with the thread mismatch, since I'm trying to associate Thread.current with Fiber.scheduler and Fiber.current.
BUUUUT I actually found a much better way to do that on JRuby, as these are exposed fairly neatly via getFiberCurrentThread and getScheduler (which will also work for fibers created before I could possibly set up a tracer).
JRuby 10.1.x is our more experimental edge version so I'm thinking I might attempt to make Thread.current always return the parent thread and we can see how that impacts real code.
The workaround you found will work in any case. I will attempt to improve the behavior of Thread.current as well as merging the trace fix.
Thanks, will do! Thought I found another issue related to Thread.current (JRuby not permitting nested Fiber.schedule calls), but just checked, and that's already fixed on master.
Activity
headius commentedon Aug 21, 2026
Right you are. This does not seem to have coverage in rubyspec but we do have a related test from the CRuby suite excluded currently. I would not expect it to be difficult to implement.
headius commentedon Aug 21, 2026
A quick attempt here: #9603
rkh commentedon Aug 22, 2026
That was quick!
FWIW, I'm not 100% sure the current patch fits my use case with the thread mismatch, since I'm trying to associate
Thread.currentwithFiber.schedulerandFiber.current.BUUUUT I actually found a much better way to do that on JRuby, as these are exposed fairly neatly via
getFiberCurrentThreadandgetScheduler(which will also work for fibers created before I could possibly set up a tracer).headius commentedon Aug 23, 2026
JRuby 10.1.x is our more experimental edge version so I'm thinking I might attempt to make Thread.current always return the parent thread and we can see how that impacts real code.
The workaround you found will work in any case. I will attempt to improve the behavior of Thread.current as well as merging the trace fix.
Initial impl of :fiber_switch trace event
Return Fiber's parent thread for Thread.current
Initial impl of :fiber_switch trace event
headius commentedon Sep 10, 2026
I'm going to call this fixed by #9603 even though
Thread.currentis still an open issue. Let me know if you run into other issues.rkh commentedon Sep 10, 2026
Thanks, will do! Thought I found another issue related to
Thread.current(JRuby not permitting nestedFiber.schedulecalls), but just checked, and that's already fixed on master.Return Fiber's parent thread for Thread.current
Return Fiber's parent thread for Thread.current