JDK-6201512 : (fc) FileChannel.map() causes IOException and crashes System (win98)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_98
  • CPU: x86
  • Submitted: 2004-11-30
  • Updated: 2010-04-02
  • Resolved: 2006-11-25
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Windows 98 [Version 4.10.1998]
Windows 98 [Version 4.10.2222]

EXTRA RELEVANT SYSTEM CONFIGURATION :
German Language

A DESCRIPTION OF THE PROBLEM :
FileChannel.map(...) causes an IOException when called often (about 600-800 times, depending on the machine). This occurs reproducible on two different Windows 98 machines. If the same Code is run twice without a reboot, the machines hang and must be rebooted using the Power switch.
The same code works as expected on Linux / JDK1.4.
Tests with JDK5 on Win98 show the same result.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create  a large File (2 MB) named 'test' in some directory.
Run the NioTest example below in that directory.
Run the example twice to hang the System.
The problem remains unchanged even if the arguments of the call to map(...) are replaced by  constants.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The output  should contain the size of the test file and a large numer of lines like
mapping position:[1]	1024
mapping position:[2]	2048
.....
ACTUAL -
File length is:	1922997
mapping position:[1]	1024
mapping position:[2]	2048
...
mapping position:[714]	731136
mapping position:[715]	732160
java.io.IOException: Die Zugriffsnummer ist nicht definiert
	at sun.nio.ch.FileChannelImpl.size0(Native Method)
	at sun.nio.ch.FileChannelImpl.size(FileChannelImpl.java:306)
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:690)
	at NioTest.main(NioTest.java:18)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: Die Zugriffsnummer ist nicht definiert
	at sun.nio.ch.FileChannelImpl.size0(Native Method)
	at sun.nio.ch.FileChannelImpl.size(FileChannelImpl.java:306)
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:690)
	at NioTest.main(NioTest.java:18)

"Die Zugriffsnummer ist nicht definiert" seems to be "The handle is invalid" translated.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.nio.*;
import java.nio.channels.*;
import java.io.*;

public class NioTest{

	public static void main(String[] args) {
System.setErr(System.out);
		try{
			File f=new File("test");
			RandomAccessFile randF=new RandomAccessFile(f, "r");

			long len=randF.getChannel().size();
			System.out.println("File length is:\t"+len);
			int size=1024;
			for (int position=size; position < Math.min(1234000000, len-size-1); position+=size){
				System.out.println("mapping position:["+(position/size)+"]\t"+position);
				randF.getChannel().map(FileChannel.MapMode.READ_ONLY, position, size);
			}

			randF.close();
		} catch (Exception ex){
			ex.printStackTrace();
		}
	}

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Do not use java.nio.* for Applications that should run on Windows 98.

Comments
EVALUATION This issue appears to be specific to Windows 9x and I am unable to reproduce it on Windows 2000 or XP. Since Windows 98 is no longer listed as a supported platform I will close this bug.
25-11-2006