Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Update 2021-04-20: this affects all ....OnOutOfMemoryError switches, not only CrashOnOutOfMemoryError. -------------- FULL PRODUCT VERSION : java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode) FULL OS VERSION : Linux xxxxx 4.0.9 #1 SMP Fri Feb 26 15:21:14 PST 2016 x86_64 x86_64 x86_64 GNU/Linux Darwin xxxxx 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/REL A DESCRIPTION OF THE PROBLEM : The newly introduced CrashOnOutOfMemoryError option doesn't appear to work when the cause of the OOM is due to not being able to create new threads. THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the program below with "java -XX:+CrashOnOutOfMemoryError Test". After a few seconds, an OutOfMemoryError (unable to create new native thread) will be printed to the console but the program won't exit. EXPECTED VERSUS ACTUAL BEHAVIOR : I would expect the VM to crash, but it keeps running. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- class Test { public static void main(String[] args) throws InterruptedException { Thread t = new Thread(() -> { while (true) { new Thread(() -> { try { Thread.currentThread().join(); } catch (InterruptedException e) { } }).start(); } }); t.start(); Thread.currentThread().join(); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Use a JVMTI agent to intercept ResourceExhausted events and forcibly exit the VM (e.g., https://github.com/airlift/jvmkill)
|