Skip to content

JavaFX AnimationTimer + Mutex.synchronize triggers “deadlock; lock already owned by another fiber belonging to the same thread” on JRuby 10.0.3.0 #9218

@yamam

Description

@yamam

Environment Information

JRuby: 10.0.3.0

Java:
openjdk 25.0.2 2026-01-20
OpenJDK Runtime Environment (build 25.0.2+10-Ubuntu-124.04)
OpenJDK 64-Bit Server VM (build 25.0.2+10-Ubuntu-124.04, mixed mode, sharing)

OS: Ubuntu 24.04.3 LTS

Steps to reproduce
Java code (JavaFXMain.java):

public class JavaFXMain extends javafx.application.Application {
    public void start(javafx.stage.Stage stage)
    {
        new org.jruby.embed.ScriptingContainer().runScriptlet("load 'JavaFX.rb'");
    }
}

Ruby code (JavaFX.rb):

Thread.abort_on_exception = true

class Timer < javafx.animation.AnimationTimer
    def initialize
        @lock = Mutex.new
        start
    end

    def handle(time)
        begin
            while true
                @lock.synchronize do
                end
            end
        rescue
            puts $!
            puts $!.backtrace
        end
    end
end

Timer.new

Thread.new do
    sleep 3
    raise
end

Compile:

javac --module-path /usr/share/openjfx/lib --add-modules javafx.controls -cp ./jruby-complete.jar JavaFXMain.java

Run:

java --module-path /usr/share/openjfx/lib --add-modules javafx.controls -cp ./jruby-complete.jar:. JavaFXMain

Expected Behavior
No deadlock occurs.

Actual Behavior
After a few seconds, the following error appears

deadlock; lock already owned by another fiber belonging to the same thread
org/jruby/ext/thread/Mutex.java:110:in 'lock'
org/jruby/ext/thread/Mutex.java:192:in 'synchronize'
JavaFX.rb:12:in 'handle'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions