Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-17 Thread Mandy Chung
On Thu, 17 Jun 2021 18:15:52 GMT, Aleksei Voitylov wrote: > Thanks Mandy for the thorough review, I'll definitely do that. Shall we wait > for Alan opinion as well? I think you can proceed posting a PR for jdk17 as the new version has addressed Alan's concern of using ThreadLocal. Alan can r

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-17 Thread Mandy Chung
On Wed, 16 Jun 2021 07:51:32 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-17 Thread Mandy Chung
On Thu, 17 Jun 2021 18:12:19 GMT, Aleksei Voitylov wrote: >> test/jdk/java/lang/ClassLoader/loadLibraryDeadlock/TestLoadLibraryDeadlock.java >> line 95: >> >>> 93: Collections.addAll(args, "cvf", Paths.get(testClassPath, >>> outputJar).toString()); >>> 94: for (String c : clas

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-17 Thread Aleksei Voitylov
On Wed, 16 Jun 2021 07:51:32 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-17 Thread Aleksei Voitylov
On Wed, 16 Jun 2021 15:59:44 GMT, Mandy Chung wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> address review comments > > test/jdk/java/lang/ClassLoader/loadLibraryDeadlock/TestLoadLibraryDeadlock.java > line

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-16 Thread Mandy Chung
On Wed, 16 Jun 2021 07:51:32 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-16 Thread Mandy Chung
On Wed, 16 Jun 2021 07:51:32 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v7]

2021-06-16 Thread Aleksei Voitylov
On Mon, 14 Jun 2021 18:30:23 GMT, Mandy Chung wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> address review comments > > test/jdk/java/lang/ClassLoader/loadLibraryDeadlock/LoadLibraryDeadlock.java > line 44:

Re: RFR: 8266310: deadlock while loading the JNI code [v8]

2021-06-16 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code [v7]

2021-06-16 Thread Aleksei Voitylov
On Fri, 11 Jun 2021 10:03:44 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-06-14 Thread Mandy Chung
On Fri, 11 Jun 2021 10:00:14 GMT, Aleksei Voitylov wrote: >> test/jdk/java/lang/ClassLoader/loadLibraryDeadlock/TestLoadLibraryDeadlock.java >> line 84: >> >>> 82: >>> 83: private static OutputAnalyzer createJar(String outputJar, String... >>> classes) throws Throwable { >>> 84:

Re: RFR: 8266310: deadlock while loading the JNI code [v7]

2021-06-14 Thread Mandy Chung
On Fri, 11 Jun 2021 10:03:44 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-06-11 Thread Aleksei Voitylov
On Mon, 31 May 2021 23:57:09 GMT, Mandy Chung wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> address review comments > > test/jdk/java/lang/ClassLoader/loadLibraryDeadlock/TestLoadLibraryDeadlock.java > line

Re: RFR: 8266310: deadlock while loading the JNI code [v7]

2021-06-11 Thread Aleksei Voitylov
On Fri, 11 Jun 2021 10:03:44 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v7]

2021-06-11 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-06-11 Thread Aleksei Voitylov
On Mon, 31 May 2021 20:56:14 GMT, Mandy Chung wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> address review comments > > src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 207: > >> 205

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-06-01 Thread Mandy Chung
On Thu, 27 May 2021 14:31:59 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-05-31 Thread Chris Hegarty
On Thu, 27 May 2021 14:31:59 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-31 Thread Peter Levart
On Thu, 27 May 2021 14:28:09 GMT, Aleksei Voitylov wrote: >> src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line >> 481: >> >>> 479: throw new Error("Maximum lock count exceeded"); >>> 480: } >>> 481: >> >> Hi Aleksei, >> I know in practice this

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-05-31 Thread Peter Levart
On Thu, 27 May 2021 14:31:59 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-05-30 Thread David Holmes
On Thu, 27 May 2021 14:31:59 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-27 Thread Aleksei Voitylov
On Fri, 21 May 2021 15:49:09 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-27 Thread Aleksei Voitylov
On Wed, 26 May 2021 07:30:10 GMT, Peter Levart wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> fix whitespace > > src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 481: > >> 479:

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-27 Thread Aleksei Voitylov
On Wed, 26 May 2021 02:36:34 GMT, David Holmes wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> fix whitespace > > src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 497: > >> 495: >> 49

Re: RFR: 8266310: deadlock while loading the JNI code [v6]

2021-05-27 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-26 Thread Mandy Chung
On Fri, 21 May 2021 15:49:09 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-26 Thread Peter Levart
On Fri, 21 May 2021 15:49:09 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-25 Thread David Holmes
On Fri, 21 May 2021 15:49:09 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-25 Thread Aleksei Voitylov
On 25/05/2021 04:44, David Holmes wrote: > On 25/05/2021 7:53 am, Aleksei Voitylov wrote: >> On Mon, 24 May 2021 06:24:15 GMT, David Holmes >> wrote: >> Aleksei Voitylov has updated the pull request incrementally with one additional commit since the last revision:    fix whit

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-24 Thread David Holmes
On 25/05/2021 7:53 am, Aleksei Voitylov wrote: On Mon, 24 May 2021 06:24:15 GMT, David Holmes wrote: Aleksei Voitylov has updated the pull request incrementally with one additional commit since the last revision: fix whitespace src/java.base/share/classes/jdk/internal/loader/NativeLibra

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-24 Thread Aleksei Voitylov
On Mon, 24 May 2021 06:24:15 GMT, David Holmes wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> fix whitespace > > src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 511: > >> 509:

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-23 Thread David Holmes
On Fri, 21 May 2021 15:49:09 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v3]

2021-05-21 Thread Jorn Vernee
On Fri, 21 May 2021 15:39:33 GMT, Aleksei Voitylov wrote: >> src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line >> 262: >> >>> 260: } finally { >>> 261: releaseNativeLibraryLock(name); >>> 262: } >> >> The new locking scheme looks incorrect t

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-21 Thread Aleksei Voitylov
Peter, David, I updated the PR to focus on solving the problem I originally intended to solve that is observed in the wild - a deadlock when two different libraries are being loaded. The case when the same library JNI_OnLoad has FindClass with a circular dependency on loading the same library is a

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-21 Thread Peter Levart
On 21/05/2021 10:29, Peter Levart wrote: I still haven't found a scenario of a possible deadlock when Sergei's initial patch is combined with... Sorry Aleksei, I renamed you to Sergei without intention. Please excuse me. Peter

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-21 Thread Aleksei Voitylov
On Fri, 21 May 2021 15:49:09 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v5]

2021-05-21 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code [v4]

2021-05-21 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code [v3]

2021-05-21 Thread Aleksei Voitylov
On Wed, 19 May 2021 18:47:52 GMT, Jorn Vernee wrote: >> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> fix trailing whitespace > > src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 262: > >> 260

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-21 Thread Peter Levart
On 21/05/2021 01:11, David Holmes wrote: Hi Peter, On 21/05/2021 12:42 am, Peter Levart wrote: Hi Aleksei, Are you trying to solve this in principle or do you have a concrete problem at hand which triggers this deadlock? If it is the later, then some rearrangement of code might do the tric

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-20 Thread David Holmes
Hi Peter, On 21/05/2021 12:42 am, Peter Levart wrote: Hi Aleksei, Are you trying to solve this in principle or do you have a concrete problem at hand which triggers this deadlock? If it is the later, then some rearrangement of code might do the trick... For example, native libraries are typi

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-20 Thread Peter Levart
Hi Aleksei, Are you trying to solve this in principle or do you have a concrete problem at hand which triggers this deadlock? If it is the later, then some rearrangement of code might do the trick... For example, native libraries are typically loaded by a class initializer of some class that

Re: RFR: 8266310: deadlock while loading the JNI code [v3]

2021-05-20 Thread Aleksei Voitylov
On Wed, 19 May 2021 16:29:33 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-19 Thread David Holmes
On 20/05/2021 2:29 am, Aleksei Voitylov wrote: On Wed, 19 May 2021 16:21:41 GMT, Aleksei Voitylov wrote: Please review this PR which fixes the deadlock in ClassLoader between the two lock objects - a lock object associated with the class being loaded, and the ClassLoader.loadedLibraryNames

Re: RFR: 8266310: deadlock while loading the JNI code [v3]

2021-05-19 Thread Jorn Vernee
On Wed, 19 May 2021 16:29:33 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-19 Thread Aleksei Voitylov
On Wed, 19 May 2021 16:21:41 GMT, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> li

Re: RFR: 8266310: deadlock while loading the JNI code [v3]

2021-05-19 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-19 Thread Aleksei Voitylov
Hi David, Mandy, In the updated PR I removed the lock held during the load/unload calls. Our testing confirmed that without that removal the deadlock can easily be reproduced, even without signed jars. Now the lock is only held to prevent races during access to "libraries" and "loadedLibraryNames"

Re: RFR: 8266310: deadlock while loading the JNI code [v2]

2021-05-19 Thread Aleksei Voitylov
> Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library > load operation. > > Problem being fixed: > > The initial

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-13 Thread David Holmes
On 14/05/2021 7:20 am, Mandy Chung wrote: On 5/13/21 6:05 AM, David Holmes wrote: Not every problem has a solution :) If JNI_OnLoad has to execute atomically with respect to loading a library then there will always be a deadlock potential. The only complete solution would not hold a lock whi

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-13 Thread Mandy Chung
On 5/13/21 6:05 AM, David Holmes wrote: Not every problem has a solution :) If JNI_OnLoad has to execute atomically with respect to loading a library then there will always be a deadlock potential. The only complete solution would not hold a lock while JNI_OnLoad is executed, but that comple

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-13 Thread David Holmes
Hi Aleksei, On 13/05/2021 9:54 pm, Aleksei Voitylov wrote: Hi David, On 12/05/2021 10:56, David Holmes wrote: Hi Aleksei, On 11/05/2021 11:19 pm, Aleksei Voitylov wrote: Please review this PR which fixes the deadlock in ClassLoader between the two lock objects - a lock object associated with

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-13 Thread Aleksei Voitylov
Hi David, On 12/05/2021 10:56, David Holmes wrote: > Hi Aleksei, > > On 11/05/2021 11:19 pm, Aleksei Voitylov wrote: >> Please review this PR which fixes the deadlock in ClassLoader between >> the two lock objects - a lock object associated with the class being >> loaded, and the ClassLoader.loade

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-13 Thread Chris Hegarty
On Tue, 11 May 2021 13:10:30 GMT, Aleksei Voitylov wrote: > Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-13 Thread Aleksei Voitylov
On Tue, 11 May 2021 13:10:30 GMT, Aleksei Voitylov wrote: > Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-12 Thread Peter Levart
On Tue, 11 May 2021 13:10:30 GMT, Aleksei Voitylov wrote: > Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-12 Thread Aleksei Voitylov
On Tue, 11 May 2021 13:28:16 GMT, Alan Bateman wrote: >> Please review this PR which fixes the deadlock in ClassLoader between the >> two lock objects - a lock object associated with the class being loaded, and >> the ClassLoader.loadedLibraryNames hash map, locked during the native >> library

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-12 Thread David Holmes
Hi Aleksei, On 11/05/2021 11:19 pm, Aleksei Voitylov wrote: Please review this PR which fixes the deadlock in ClassLoader between the two lock objects - a lock object associated with the class being loaded, and the ClassLoader.loadedLibraryNames hash map, locked during the native library load

Re: RFR: 8266310: deadlock while loading the JNI code

2021-05-11 Thread Alan Bateman
On Tue, 11 May 2021 13:10:30 GMT, Aleksei Voitylov wrote: > Please review this PR which fixes the deadlock in ClassLoader between the two > lock objects - a lock object associated with the class being loaded, and the > ClassLoader.loadedLibraryNames hash map, locked during the native library

RFR: 8266310: deadlock while loading the JNI code

2021-05-11 Thread Aleksei Voitylov
Please review this PR which fixes the deadlock in ClassLoader between the two lock objects - a lock object associated with the class being loaded, and the ClassLoader.loadedLibraryNames hash map, locked during the native library load operation. Problem being fixed: The initial reproducer demon