JDK-6772303 : (se) IOException: Invalid argument" thrown on a call to Selector.select(value) with -d64
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0u12,5.0u15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9,solaris_10
  • CPU: x86,sparc
  • Submitted: 2008-11-17
  • Updated: 2010-07-29
  • Resolved: 2009-04-11
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
6u18Fixed 7 b55Fixed
Related Reports
Duplicate :  
Description
On a SunFire X4200 (4 x 2593 MHz, 8192 MB) with Solaris 10:
$ cat /etc/release
                        Solaris 10 8/07 s10x_u4wos_12b X86
           Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 16 August 2007

the following application will throw an exception on the call to Selector's select() when the application is launched with the -d64 flag. This problem is systematically reproduced on one machine (the one described above - remulac) and it never happens on other platforms or on the same one but using the -d32 flag.


--0<- bug.java --0<---0<---0<---0<---0<---0<---0<---0<--
import java.io.*;
import java.nio.channels.Selector;

class bug {
    public static void main(String[] arg) {
    
	Selector selector = null;
    
        try {
            System.out.println("Opening selector");
	    selector = Selector.open();

            System.out.println("Waiting on selector");
	    selector.select(2000);
            System.out.println("Waited 2000 ms");

            System.out.println("Closing selector");
	    selector.close();
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}
--0<---0<---0<---0<---0<---0<---0<---0<---0<--


This is what happens:

$ java -d64 bug
Opening selector
Waiting on selector
java.io.IOException: Invalid argument
        at sun.nio.ch.DevPollArrayWrapper.poll0(Native Method)
        at sun.nio.ch.DevPollArrayWrapper.poll(DevPollArrayWrapper.java:164)
        at sun.nio.ch.DevPollSelectorImpl.doSelect(DevPollSelectorImpl.java:68)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
        at bug.main(bug.java:14)

Comments
WORK AROUND ulimit -n 1024
02-12-2008

EVALUATION The /dev/poll Selector uses getrlimit(2) to determine the hard limit on the number of open files (as this is required to size the poll array). On the submitter's machine, the hard limit is returned "-3" because /etc/system has a line "set rlim_fd_max = -3". This is RLIM64_INFINITY which is not handled correctly in our implementation.
02-12-2008

EVALUATION I successfully reproduced the bug using both 1.5.0_12 and 1.6.0_10: remulac$ java -version java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode) remulac$ java -d64 bug Opening selector Waiting on selector java.io.IOException: Invalid argument at sun.nio.ch.DevPollArrayWrapper.poll0(Native Method) at sun.nio.ch.DevPollArrayWrapper.poll(DevPollArrayWrapper.java:164) at sun.nio.ch.DevPollSelectorImpl.doSelect(DevPollSelectorImpl.java:68) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80) at bug.main(bug.java:14)
02-12-2008

EVALUATION Can you say if this duplicates with jdk6? If not, this is likely to be a duplicate of 6322825.
02-12-2008