JDK-6973831 : NPE when printing stack trace of OOME
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6u12,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2010-08-02
  • Updated: 2014-05-06
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b109Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
JDK7 b102 fails with the following exception when calling method printStackTrace() on OutOfMemoryException object:

java.lang.NullPointerException 
at java.lang.Throwable.printStackTrace(Throwable.java:563)                                                      at java.lang.Throwable.printStackTrace(Throwable.java:548)                                              ...

The problem doesn't occur in older builds (b100, b101).

The code change that seems to be most related to this bug is CR 6911258 commit.

Comments
SUGGESTED FIX http://hg.openjdk.java.net/jdk7/tl/jdk/rev/389bc53d0945
12-08-2010

EVALUATION The OOM objects are preallocated at VM initialization and the constructor cannot be invoked. Another option could be to initialize the fields individually in the VM when VM initialization is finished. It doesn't handle the case when new fields are added in the OOM object in the future if the new fields have to be non-null that would require a VM synchronized change. Initializing the suppressedExceptions to be null is a better option.
11-08-2010

EVALUATION The VM preallocated OutOfMemoryError are created without runniing the OutOfMemoryError constructor. This is how the hotspot VM disallows finalizable perm objects to be created in the current implementation. Hence, the suppressedExceptions field in the preallocated OOM object is null in this case and NPE is thrown since it's expected to be non-null. Two options to fix this: 1. Change the OutOfMemoryError.suppressedExceptions field to be initialized to null instead of Collections.emptyList(). 2. Change VM to run OutOfMemoryError.<init> for its preallocated OOM objects.
09-08-2010

PUBLIC COMMENTS Please see comments for further information.
02-08-2010