Closed hinerm closed 1 month ago
Note: this happens with Java 8.
Will test with pom-scijava 38 to see if that helps
pom-scijava 38.0.1 did not fix things
I just dug into the threads and think I found the source of the deadlock. In thread main
we dispose the Context
which calls doDispose
which is synchronized:
Then on the EDT when ij.ImageJ
is closed (via its run
method) it calls its dispose
method which we have a hook in to dispose our Context
:
Which, of course, it cannot do because main
has a lock on the Context
.
This seems like an infinite loop since whenever the Context
is disposed it will lead to the LegacyService
disposing, which will cause ij.ImageJ
to dispose, which will cause the Context
to dispose, which etc, etc...
This is 🤯 to me but my first thought is that if ImageJ
shuts down first then its disposing
flag is true
and this line short-circuits and no infinite loop.
I'm wondering if this test is insufficient and missing the case where we shut down from the Context
first...
I'm wondering if this test is insufficient and missing the case where we shut down from the Context first...
On the main
thread, the helper is EideticIJ1Helper@5886
, with the disposing
state set appropriately, but on the EDT
the helper is IJ1Helper@7470
that doesn't know it's disposing. Can't have that...
I ran into two scenarios where the tests hang (building with
mvn clean install
on the command line):MacroRecorderPostprocessorTest
(also seems to hang running in IntelliJ)On Linux (Ubuntu 24 via WSL2) I didn't get pastSee https://github.com/imagej/imagej-legacy/issues/306BatchModeTest
(hanging again)