JDK-4774886 : (se) select() throws Error for POLLNVAL
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2002-11-06
  • Updated: 2002-11-20
  • Resolved: 2002-11-20
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.
Other
1.4.2 mantisFixed
Related Reports
Relates :  
Description

Name: nt126004			Date: 11/06/2002


FULL PRODUCT VERSION :
$ java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


FULL OPERATING SYSTEM VERSION : Linux 2.2.14


A DESCRIPTION OF THE PROBLEM :
when doing select() on a descriptor, a
java.lang.Error is thrown when a POLLNVAL
is detected.

This normally is not a fatal condition
and indicates that one or more of file
descriptors registered with the selector
are invalid.

Yet Java reports it not as an Exception
but as a java.lang.Error, normally reserved
for fatal and uncorrectable errors.

In my application, it simply kills a thread
and eventually the whole application.

I am moving to intercept and deal with
this java.lang.Error, yet was wondering
if it should be moved to become Exception
intstead ?

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create a selector
2. register a number of SocketChannels
3. eventually, as select() is called,
POLLNVAL might get reported.

EXPECTED VERSUS ACTUAL BEHAVIOR :
POLLNVAL is expected to be a subclass of
Exception, not Error

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.Error: POLLNVAL detected
at sun.nio.ch.SocketChannelImpl.translateAndSetReadyOps (
SocketChannelImpl.java:671)
*****
*****
*****
( the rest of stacktrace skipped)

REPRODUCIBILITY :
This bug can be reproduced occasionally.

---------- BEGIN SOURCE ----------
NEXT_SELECT:
while(true) {
        try {
          i = writeSelector.select();
        } catch (Exception ex) {
              ex.printStackTrace();
              continue NEXT_SELECT;
        }
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
I will try to catch java.lang.Error in the try() block
and see if I can simply repeat the select() and if it
will cure the problem.
(Review ID: 165640) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b08
14-06-2004

EVALUATION This error should be thrown only if there's bug in the underlying native code, or perhaps in the kernel. We need a standalone test case or, failing that, a more complete description of the user's application in order to proceed further. For example, how many channels are being managed by the selector, and to what concurrent operations are they subjected as a selection operation is in progress? -- ###@###.### 2002/11/13 I take that back. While investigating 4696508 I realized that POLLNVAL can legitimately occur in the case of a channel that's asynchronously closed since when that happens we dup the underlying file descriptor to a special fd that's already closed. The throw new Error() statements have been removed. -- ###@###.### 2002/11/14
11-10-0180