United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6772303 (se) IOException: Invalid argument" thrown on a call to Selector.select(value) with -d64
6772303 : (se) IOException: Invalid argument" thrown on a call to Selector.select(value) with -d64

Details
Type:
Bug
Submit Date:
2008-11-17
Status:
Resolved
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
2009-04-11
Component:
core-libs
OS:
solaris_9,solaris_10
Sub-Component:
java.nio
CPU:
x86,sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0u12,5.0u15
Fixed Versions:
7

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

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
EVALUATION

Can you say if this duplicates with jdk6? If not, this is likely to be a duplicate of 6322825.
                                     
2008-12-02
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)
                                     
2008-12-02
WORK AROUND

ulimit -n 1024
                                     
2008-12-02
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.
                                     
2008-12-02



Hardware and Software, Engineered to Work Together