Code review request: 6973831 NPE when printing stack trace of OOME

Mandy Chung mandy.chung at oracle.com
Wed Aug 11 19:09:46 UTC 2010


  Fix for 6973831: NPE when printing stack trace of OOME

Webrev at:
    http://cr.openjdk.java.net/~mchung/6973831/webrev.00/

The VM preallocates OutOfMemoryError objects to improve OOM 
diagnosability. The constructor is not invoked since the OOME object 
allocation is done at VM initialization time and thus the new 
suppressedExceptions field is null which causes NPE when 
Throwable.printStackTrace() method is called on the VM preallocated OOM 
object.

The fix is to initialize the suppressedExceptions field to null instead 
of Collections.emptyList().  An alternative could be to initialize the 
suppressedException field in the VM after VM initialization is 
finished.  It doesn't handle the case when any new field initialized to 
be non-null is added in the OOM object in the future and it would 
require a VM synchronized change.  The libraries fix is simpler and 
preferred.

Thanks
Mandy



More information about the core-libs-dev mailing list