RFR: 8289919: [test] LoadLibraryUnloadTest.java failed with "Failed to unload native library" [v3]
Mandy Chung
mchung at openjdk.org
Thu Jul 14 15:34:58 UTC 2022
On Thu, 14 Jul 2022 15:24:20 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> The test `java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnloadTest.java`
>> Fails intermittently when expected output from a subprocess is not found.
>>
>> I suspect a race between the Cleaner that is going to call JNI_OnUnload (in NativeLibraries.java:377) when the ClassLoader is no longer referenced and the test code that exits as soon as it detects that the p.Class1 is no longer referenced.
>>
>> The proposed fix is to create a canary object referenced by the native library and released when the library is unloaded.
>> The Java side of the test provides the canary object and uses a WeakReference to wait for it to be released.
>> When released the child process exits and the driver test will find all of the output it expects.
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix racy canary setting and improve timeout/failure messaging
test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java line 168:
> 166: for (int i = 0; i < LOADER_COUNT; i++) {
> 167: System.gc();
> 168: var res = refQueue.remove(5 * 1000L);
I suggest to use the jtreg timeout factor here (similar to what test/lib/jdk/test/lib/util/ForceGC.java` has done).
-------------
PR: https://git.openjdk.org/jdk/pull/9474
More information about the core-libs-dev
mailing list