JDK-7034155 : (ch) NullPointerException in sun.io.ch.IOUtil when OOM is thrown
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 6u24,6u26
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_redhat_4.0,solaris_10
  • CPU: x86,sparc
  • Submitted: 2011-04-05
  • Updated: 2012-03-20
  • Resolved: 2011-06-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 6 JDK 7
6u27Fixed 7 b140Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
JDK 6.0.23, but from looking at the sources the same problem is in the head revision of java 6 and java 7 code base

ADDITIONAL OS VERSION INFORMATION :
red hat linux 4.0

A DESCRIPTION OF THE PROBLEM :
java.lang.NullPointerException
        at sun.nio.ch.Util.free(Util.java:199)
        at sun.nio.ch.Util.offerFirstTemporaryDirectBuffer(Util.java:176)
        at sun.nio.ch.IOUtil.read(IOUtil.java:181)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)

This occurs when running a large proprietory grid application that is extensively using NIO. From looking at the code is appears that
the problem is in sun.io.ch.IOUtil line 172/174. Line 174 should be outside of the try block. If Util.getTemporaryBuffer() fails (e.g. due to an OOM, then the finally block is executed which would cause this exception.

We are unable to verify that this is the cause of the issue. This diagnosis is by the code inspection. We have rolled the application back to 6.0.16 and have not experienced the issue again

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
We cannot generate a test case. This occurred on an operational system running 24/7 unter heavy IO load for several days, and this exception was noted.

Due to this we cannot repoduce this locally

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception should be thrown
ACTUAL -
exception reported was thrown

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
        at sun.nio.ch.Util.free(Util.java:199)
        at sun.nio.ch.Util.offerFirstTemporaryDirectBuffer(Util.java:176)
        at sun.nio.ch.IOUtil.read(IOUtil.java:181)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)


REPRODUCIBILITY :
This bug can be reproduced occasionally.

CUSTOMER SUBMITTED WORKAROUND :
revert to 1.6.16

Due to the sporadic nature of this issue we cannot be sure that this is a fix, or if it affects some other side effects that do not manifest the problem, but we have not seen this issue for a couple of weeks now, when is was occurring once every few days on each node in a farm

Comments
EVALUATION The description is correct and NPE will be thrown if a temporary buffer cannot be allocated, thus masking the OutOfMemoryError.
06-04-2011