Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6772683
Votes 0
Synopsis Thread.isInterrupted() fails to return true on multiprocessor PC
Category hotspot:compiler2
Reported Against
Release Fixed hs16(b04), 5.0u21(b01) (Bug ID:2179065) , 7(b61) (Bug ID:2179094) , 6u16-rev(b02) (Bug ID:2179910) , 6u18(b01) (Bug ID:2180632)
State 11-Closed, Verified, bug
Priority: 4-Low
Related Bugs
Submit Date 18-NOV-2008
Description
FULL PRODUCT VERSION :
On Windows Vista 64-Bit:
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)

java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_16-b02, mixed mode)

java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b39)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b06, mixed mode)

On Linux Ubuntu 64-Bit:
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Server VM (build 1.5.0_16-b02, mixed mode)

java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_16-b02, mixed mode)

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)

java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)

java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b39)
Java HotSpot(TM) Server VM (build 14.0-b06, mixed mode)

java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b39)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b06, mixed mode)


ADDITIO xxxxx L OS VERSION INFORMATION :
 customer  Windows [version 6.0.6001] 64-Bit edition
Linux QuadCore 2.6.24-19-generic #1 SMP Wed Aug 20 17:53:40 UTC 2008 x86_64 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
CPU: Q6600
memory: 4Gb


A DESCRIPTION OF THE PROBLEM :
While running two simultaneous threads, the first thread interrupts the second one using Thread.interrupt().
The second thread tests if it has been interrupted calling the Thread.isInterrupted() method which always returns false.

This occurs on a multiprocessor PC running a 64-Bit OS (Vista and Linux).
On Vista 64-Bit, this occurs when using a 64-bit JVM (all versions from 1.5 to 1.7), but does not occur when using a 32-bit JVM.
On Linux 64-bit, this occurs when using a 64-bit JVM (all versions from 1.5 to 1.7) or when using a 32-bit JVM (all versions from 1.5 to 1.7).


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. In the following program, the main thread creates a worker thread.
2. The worker thread enters in an infinite loop until it is interrupted. (calling the isInterrupted() method)
3. The main thread waits for the worker thread to die with a timeout of 1 second.
4. The main thread interrupts the worker thread and waits for it to die.
5. The worker thread continuously calls the isInterrupted() method that always return false whereas the thread is interrupted !


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Thread.isInterrupted() method should return true and the worker thread should exit.
Here is output of the program executed with a 32-bit JVM on Vista 64-Bit:

Main thread: starts a worker thread...
Main thread: waits at most 1s for the worker thread to die...
Worker thread: running...
Main thread: interrupts the worker thread...
Worker thread: bye
Main thread: worker thread is interrupted
Main thread: waits for the worker thread to die...
Main thread: bye
ACTUAL -
The Thread.isInterrupted() method returns false and the worker thread never exit.
Here is output of the program executed with a 64-bit JVM on Vista 64-Bit:

Main thread: starts a worker thread...
Main thread: waits at most 1s for the worker thread to die...
Worker thread: running...
Main thread: interrupts the worker thread...
Main thread: worker thread is interrupted
Main thread: waits for the worker thread to die...

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class InterruptedTest {

    public static void main(String[] args) throws Exception {
        Thread workerThread = new Thread("worker") {
            public void run() {
                System.out.println("Worker thread: running...");
                while (!Thread.currentThread().isInterrupted()) {
                }
                System.out.println("Worker thread: bye");
            }
        };
        System.out.println("Main thread: starts a worker thread...");
        workerThread.start();
        System.out.println("Main thread: waits at most 1s for the worker thread to die...");
        workerThread.join(1000);
        if (workerThread.isAlive()) {
            System.out.println("Main thread: interrupts the worker thread...");
            workerThread.interrupt();
            if (workerThread.isInterrupted()) {
                System.out.println("Main thread: worker thread is interrupted");
            }
            System.out.println("Main thread: waits for the worker thread to die...");
            workerThread.join();
        }
        System.out.println("Main thread: bye");
    }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Calling Thread.yield() before Thread.isInterrupted() bypasses the bug.
Calling Thread.interrupted() instead of Thread.isInterrupted() bypasses the bug.
Posted Date : 2008-11-18 04:57:53.0
Work Around
N/A
Evaluation
C2 has an instrinic implementation of isInterrupt to avoid the call into the VM for the case that the receiver is the current thread. The issue is likely to be there as this doesn't duplicate with the client VM or with -Xint.
Posted Date : 2009-05-19 09:17:37.0

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/aabd393cf1ee
Posted Date : 2009-05-21 20:48:39.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang