RFR: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

Weijun Wang-2
`InetAddress` is loading native library `net` and at the same time `SunNativeProvider` is loading `j2gss`, and in the `OnLoad` function inside `j2gss` it is calling `FindClass(env, "java/net/InetAddress")` and thus a deadlock.

We can access `InetAddress` in `SunNativeProvider.<clinit>` before loading the jgss library. i.e. use `Class.forName` to ensure `InetAddress` is initialized. Thanks to @dholmes-ora for providing this workaround.

No new regression test, hard to reproduce.

-------------

Commit messages:
 - 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

Changes: https://git.openjdk.java.net/jdk/pull/2655/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2655&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8210373
  Stats: 3 lines in 1 file changed: 1 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2655.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2655/head:pull/2655

PR: https://git.openjdk.java.net/jdk/pull/2655
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

Xue-Lei Andrew Fan
On Fri, 19 Feb 2021 21:44:15 GMT, Weijun Wang <[hidden email]> wrote:

> `InetAddress` is loading native library `net` and at the same time `SunNativeProvider` is loading `j2gss`, and in the `OnLoad` function inside `j2gss` it is calling `FindClass(env, "java/net/InetAddress")` and thus a deadlock.
>
> We can access `InetAddress` in `SunNativeProvider.<clinit>` before loading the jgss library. i.e. use `Class.forName` to ensure `InetAddress` is initialized. Thanks to @dholmes-ora for providing this workaround.
>
> No new regression test, hard to reproduce.

src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java line 74:

> 72:                             System.getProperty("sun.security.nativegss.debug"));
> 73:                         try {
> 74:                             Class.forName("java.net.InetAddress");

The returned value of Class.forName() is not used, someone else could delete this line later is he/she does not know the story behind this line.  Would you mind add a few line comments about why it is added?

Otherwise, looks good to me.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2655
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

Weijun Wang-2
On Mon, 22 Feb 2021 18:33:17 GMT, Xue-Lei Andrew Fan <[hidden email]> wrote:

>> `InetAddress` is loading native library `net` and at the same time `SunNativeProvider` is loading `j2gss`, and in the `OnLoad` function inside `j2gss` it is calling `FindClass(env, "java/net/InetAddress")` and thus a deadlock.
>>
>> We can access `InetAddress` in `SunNativeProvider.<clinit>` before loading the jgss library. i.e. use `Class.forName` to ensure `InetAddress` is initialized. Thanks to @dholmes-ora for providing this workaround.
>>
>> No new regression test, hard to reproduce.
>
> src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java line 74:
>
>> 72:                             System.getProperty("sun.security.nativegss.debug"));
>> 73:                         try {
>> 74:                             Class.forName("java.net.InetAddress");
>
> The returned value of Class.forName() is not used, someone else could delete this line later is he/she does not know the story behind this line.  Would you mind add a few line comments about why it is added?
>
> Otherwise, looks good to me.

Definitely. I should have added one. Thanks for reminding.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2655
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel. [v2]

Weijun Wang-2
In reply to this post by Weijun Wang-2
> `InetAddress` is loading native library `net` and at the same time `SunNativeProvider` is loading `j2gss`, and in the `OnLoad` function inside `j2gss` it is calling `FindClass(env, "java/net/InetAddress")` and thus a deadlock.
>
> We can access `InetAddress` in `SunNativeProvider.<clinit>` before loading the jgss library. i.e. use `Class.forName` to ensure `InetAddress` is initialized. Thanks to @dholmes-ora for providing this workaround.
>
> No new regression test, hard to reproduce.

Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:

  Add comment

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2655/files
  - new: https://git.openjdk.java.net/jdk/pull/2655/files/cf3feb4c..c63068c8

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2655&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2655&range=00-01

  Stats: 3 lines in 1 file changed: 3 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2655.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2655/head:pull/2655

PR: https://git.openjdk.java.net/jdk/pull/2655
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel. [v2]

Xue-Lei Andrew Fan
On Mon, 22 Feb 2021 20:56:09 GMT, Weijun Wang <[hidden email]> wrote:

>> `InetAddress` is loading native library `net` and at the same time `SunNativeProvider` is loading `j2gss`, and in the `OnLoad` function inside `j2gss` it is calling `FindClass(env, "java/net/InetAddress")` and thus a deadlock.
>>
>> We can access `InetAddress` in `SunNativeProvider.<clinit>` before loading the jgss library. i.e. use `Class.forName` to ensure `InetAddress` is initialized. Thanks to @dholmes-ora for providing this workaround.
>>
>> No new regression test, hard to reproduce.
>
> Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:
>
>   Add comment

Looks good to me.

-------------

Marked as reviewed by xuelei (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2655
Reply | Threaded
Open this post in threaded view
|

Integrated: 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

Weijun Wang-2
In reply to this post by Weijun Wang-2
On Fri, 19 Feb 2021 21:44:15 GMT, Weijun Wang <[hidden email]> wrote:

> `InetAddress` is loading native library `net` and at the same time `SunNativeProvider` is loading `j2gss`, and in the `OnLoad` function inside `j2gss` it is calling `FindClass(env, "java/net/InetAddress")` and thus a deadlock.
>
> We can access `InetAddress` in `SunNativeProvider.<clinit>` before loading the jgss library. i.e. use `Class.forName` to ensure `InetAddress` is initialized. Thanks to @dholmes-ora for providing this workaround.
>
> No new regression test, hard to reproduce.

This pull request has now been integrated.

Changeset: 991f7c13
Author:    Weijun Wang <[hidden email]>
URL:       https://git.openjdk.java.net/jdk/commit/991f7c13
Stats:     6 lines in 1 file changed: 4 ins; 0 del; 2 mod

8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel.

Reviewed-by: xuelei

-------------

PR: https://git.openjdk.java.net/jdk/pull/2655