RFR: 8231584: Deadlock with ClassLoader.findLibrary and System.loadLibrary call
akozlov at azul.com
Fri Sep 27 16:37:39 UTC 2019
I think that JDK-8194653  affects jdk/jdk and it doesn't specific to FileSystems.getDefault.
I'm starting a new thread/bug as the original issue marked as resolved ()
Ryan, thanks for investigation and providing a test !
But the test fails in the same way if the FileSystems.getDefault replaced with anything that calls System.loadLibrary in an initializer. For jdk/jdk it may be jdk.net.ExtendedSocketOptions.SO_FLOW_SLA and the issue will arise.
I don't think it's possible to provide a general fix for that. We are unable to prevent a user to take the Runtime's monitor and do initialization and loadLibrary, which make a room for deadlock. Taking the lock is incorrect action at first. We can only prevent doing that by accident.
>From the original deadlock report , initialization and loadLibrary under the monitor caused not by java.* code, but class loader's findLibrary (sun.misc.ExtClassLoader to be specific). A workaround for ExtClassLoader is possible, to ensure all necessary classes are inited before findLibrary called, i.e. in the constructor. But then we should require the same for any custom class loader. Chances that it would be implemented correctly are not high since even ExtClassLoader is flawed.
I propose to call a ClassLoader.findLibrary with Runtime's monitor unlocked:
More information about the core-libs-dev