JDK-6988618 : JCK test setDaemon0101 hangs on specific machine
Type:Bug
Component:core-libs
Sub-Component:java.lang
Affected Version:7
Priority:P2
Status:Resolved
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2010-09-30
Updated:2012-02-02
Resolved:2010-11-23
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.
JCK test setDaemon0101 hangs on SuSE 11 machine starting JCK 7 b21.
The hang happens because ThreadGroup.isDestroyed() never returns true for empty daemon thread group.
EVALUATION
Basically we decrement the unstarted thread count in threadStarting. Since the thread is added to the group the reason for the unstarted thread count is no longer applicable, i.e. the thread is a real member of the group. We rectify the unstarted thread count if start fails, allowing a subsequent attempt to start the thread (this is consistent with current behavior).
Changeset: 8e5c27614fec
Author: chegar
Date: 2010-11-05 09:07 +0000
URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/8e5c27614fec
6988618: JCK test setDaemon0101 hangs on specific machine
Reviewed-by: dholmes, alanb
! src/share/classes/java/lang/Thread.java
! src/share/classes/java/lang/ThreadGroup.java
05-11-2010
EVALUATION
The test would appear to be valid.
My suspicion is that this test started failing since JDK7_b21 because of the fix for 6379235: "ThreadGroup accounting mistake possible with failure of Thread.start()". The test creates one thread within a daemon thread group and then waits for that thread to complete. Expecting the thread group will be destroyed.
There is a race, if the thread being created completes before the starting thread has a chance to complete its start method ( and decrement the groups nUnstartedThreads count ), then when the newly started threads exit method notifies the group that it is terminating the group will not be destroyed because it believes it still as an unstarted thread in it.
01-10-2010
PUBLIC COMMENTS
This issue is not specific to SuSE 11, it should be reproducible on any OS/platform. I reproduced it on Linux-i586 and Solaris-sparc. Simply rerun the test over and over with 'repeat 1000 java ....'