- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    8, 11
- 
        b11
- 
        x86_64
- 
        linux
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8298237 | 11.0.19-oracle | Prasadarao Koppula | P4 | Resolved | Fixed | b01 | 
| JDK-8299588 | 11.0.19 | Goetz Lindenmaier | P4 | Resolved | Fixed | b01 | 
| JDK-8298440 | 8u371 | Prasadarao Koppula | P4 | Resolved | Fixed | b01 | 
$ uname -a
Linux ip-172-31-5-194.ec2.internal 4.14.62-70.117.amzn2.x86_64 #1 SMP Fri Aug 10 20:14:53 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ rpm -q glibc
glibc-2.26-28.amzn2.0.1.x86_64
$ getconf GNU_LIBPTHREAD_VERSION
NPTL 2.26
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
A DESCRIPTION OF THE PROBLEM :
I ran into this deadlock when running GSSManager.getInstance() and InetAddress.getLocalHost() in parallel. From a thread dump I found that GSSManager.getInstance() is loading SunNativeProvider and it gets stuck during class loading trying to load "j2gss". See here: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java#l75 . InetAddress loads "net" at class load: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/net/InetAddress.java#l273
Loading these two libraries in parallel seems to cause the deadlock.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached code.
$ javac -d bin -sourcepath src src/com/test/BugTest.java
$ java -cp bin com.test.BugTest
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The process completes.
ACTUAL -
The process hangs.
---------- BEGIN SOURCE ----------
package com.test;
import java.net.InetAddress;
public class BugTest {
public static void main(String[] args) throws InterruptedException {
Thread load_j2gss = new Thread(() -> System.loadLibrary("j2gss"));
Thread load_net = new Thread(() -> getHostname());
load_j2gss.start();
load_net.start();
Thread.sleep(30000);
if (load_j2gss.isAlive() || load_net.isAlive()) {
System.out.println("Hung!!!!");
}
System.out.println("Done");
}
private static void getHostname() {
try {
InetAddress.getLocalHost();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Load libraries sequentially.
FREQUENCY : often
- backported by
- 
                    JDK-8298237 Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel. -           
- Resolved
 
-         
- 
                    JDK-8298440 Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel. -           
- Resolved
 
-         
- 
                    JDK-8299588 Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel. -           
- Resolved
 
-         
- duplicates
- 
                    JDK-8262052 sun/security/krb5/Permissions.java timed out -           
- Closed
 
-         
- links to
- 
                     Commit
        openjdk/jdk11u-dev/d2c8326a Commit
        openjdk/jdk11u-dev/d2c8326a
- 
                     Commit
        openjdk/jdk/991f7c13 Commit
        openjdk/jdk/991f7c13
- 
                     Review
        openjdk/jdk11u-dev/1627 Review
        openjdk/jdk11u-dev/1627
- 
                     Review
        openjdk/jdk/2655 Review
        openjdk/jdk/2655