Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4192396

1.2 native threads: interruptible I/O doesn't clear interruted bit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P2 P2
    • None
    • 1.2.0
    • hotspot
    • None
    • sparc
    • solaris_2.6

      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.

            never Tom Rodriguez
            dlstrick Douglas Strickland (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: