JDK-4125230 : 1.2 native threads: interruptible I/O doesn't clear interruted bit
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1998-04-02
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
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.2.0 1.2beta4Fixed
Related Reports
Relates :  
Description
The native threads code which implements interruptible I/O doesn't properly clear the interrupted flag so even though it properly reports that it was interrupted, code which executes later may reraise the interrupt even though it really already been serviced.  This interacts badly with the new uninterruptible monitors code since you can end up repeatedly reraising the interrupt and get something that looks like feedback.  Here's a test case and an example of the broken code in action.

public class Test extends Thread
{
    static Thread main;
    static Thread second;

    public static void main(String[] args) throws Exception {
        try {
        byte buffer[] = new byte[100];
        main = Thread.currentThread();
        second = new Test();
        second.start();
        System.in.read(buffer);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    Test() {
    }

    public void run() {
        try {
            Thread.sleep(1000);
            System.out.println("Sleep done");
            Test.main.interrupt();
            System.out.println("Interrupt done");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


never@boojum ~ 717 % /usr/local/java/jdk1.2/solaris/bin/java -native Test
Sleep done
Interrupt done
java.io.InterruptedIOException: Interrupted system calljava.io.InterruptedIOException: Interrupted system call
java.io.InterruptedIOException: Interrupted system call
java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)
java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)
java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)
java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)

java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)

java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)

java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)


java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)


java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)


java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)



java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)



java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)



java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)




java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)




java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)




java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)





java.io.InterruptedIOException: Interrupted system call
        at java.io.FileInputStream.readBytes(Native Method)




The code should actually only print the exception one and exit.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

SUGGESTED FIX The code which catches the interrupted I/O case should clear the interrupted state. This is in src/solaris/hpi/native_threads/src/sys_api_td.c.
11-06-2004

EVALUATION That's a bug all right. tom.rodriguez@Eng 1998-04-02
02-04-1998