JDK-4692059 : Reg-test LostOwnershipChainTest/SystemClipboard2ProcTest.html failing
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-05-27
  • Updated: 2003-04-12
  • Resolved: 2002-08-08
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.4.2 mantisFixed
Related Reports
Relates :  
Relates :  
Description

Name: agR10216			Date: 05/27/2002

###@###.###
#Test Results (version 2)
#Mon May 27 18:17:01 MSD 2002
#checksum:5b13aa28dd0e900
#-----testdescription-----
$file=E:\\TEMP\\test\\SystemClipboard2ProcTest.html
$root=E:\\TEMP\\test
author=###@###.### area=Clipboard
keywords=bug4683804
run=USER_SPECIFIED applet SystemClipboard2ProcTest.html\r\n
source=SystemClipboard2ProcTest.html
title=Tests that in ClipboardOwner.lostOwnership() Clipboard.getContents()             returns actual contents of the clipboard and Clipboard.setContents()             can set contents of the clipboard and its owner

#-----environment-----

#-----testresult-----
description=file:///E:/TEMP/test/SystemClipboard2ProcTest.html
end=Mon May 27 18:17:01 MSD 2002
environment=regtest
execStatus=Failed. Execution failed: Applet thread threw exception: java.lang.RuntimeException: test failed: can not get actual contents of the clipboard or set owner of the clipboard
javatestOS=Windows NT 4.0 (x86)
javatestVersion=2.1.6
script=com.sun.javatest.regtest.RegressionScript
sections=script_messages build compile applet
start=Mon May 27 18:16:30 MSD 2002
status=Failed. Execution failed: Applet thread threw exception: java.lang.RuntimeException: test failed: can not get actual contents of the clipboard or set owner of the clipboard
test=SystemClipboard2ProcTest.html
work=E:\\TEMP\\test\\JTwork\\.

#section:script_messages
----------messages:(4/212)----------
JDK under test: (W:/)
java version "1.4.1-internal"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-internal-gas_22_may_2002_16_00)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b12, mixed mode)

#section:build
----------messages:(3/114)----------
command: build SystemClipboard2ProcTest
reason: Named class compiled on demand
elapsed time (seconds): 17.829
result: Passed. Compilation successful

#section:compile
----------messages:(3/148)*----------
command: compile E:\\TEMP\\test\\SystemClipboard2ProcTest.java
reason: .class file out of date or does not exist
elapsed time (seconds): 17.781
----------System.out:(0/0)----------
----------System.err:(0/0)----------
result: Passed. Compilation successful

#section:applet
----------messages:(3/153)----------
command: applet SystemClipboard2ProcTest.html
reason: User specified action: run applet SystemClipboard2ProcTest.html
elapsed time (seconds): 11.234
----------System.out:(0/0)----------
----------System.err:(11/688)----------
0 Clipboard.setContents(): 0
0 lost clipboard ownership
========= Child VM System.err ========
1 Clipboard.setContents(): 1
======================================
chain of calls of lostOwnership() broken!
java.lang.RuntimeException: test failed: can not get actual contents of the clipboard or set owner of the clipboard
        at SystemClipboard2ProcTest.start(SystemClipboard2ProcTest.java:77)
        at com.sun.javatest.regtest.AppletWrapper$AppletThread.run(AppletWrapper.java:145)
        at java.lang.Thread.run(Thread.java:536)
STATUS:Failed.Applet thread threw exception: java.lang.RuntimeException: test failed: can not get actual contents of the clipboard or set owner of the clipboard
result: Failed. Execution failed: Applet thread threw exception: java.lang.RuntimeException: test failed: can not get actual contents of the clipboard or set owner of the clipboard


test result: Failed. Execution failed: Applet thread threw exception: java.lang.RuntimeException: test failed: can not get actual contents of the clipboard or set owner of the clipboard

###@###.### 2002-05-27
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis mantis-b02 FIXED IN: mantis mantis-b02 INTEGRATED IN: mantis mantis-b02 VERIFIED IN: mantis
17-09-2004

WORK AROUND Name: agR10216 Date: 05/27/2002 ======================================================================
17-09-2004

PUBLIC COMMENTS .
17-09-2004

EVALUATION Name: agR10216 Date: 05/31/2002 Sometimes child VM terminates before lostOwnership() is called on an object in this VM. ###@###.### 2002-05-30 ====================================================================== Name: dsR10078 Date: 06/06/2002 After the test is fixed, it still occasionally fails on timeout on Linux. Investigation shows that child VM hangs because of a deadlock: ------------------------------------------------------------------------------------------------- Found one Java-level deadlock: ============================= "AWT-EventQueue-0": waiting to lock monitor 0x808d32c (object 0x46bedac0, a java.lang.Class) in JNI, which is held by "AWT-Motif" "AWT-Motif": waiting to lock monitor 0x808d444 (object 0x42b24220, a sun.awt.motif.X11Clipboard), which is held by "AWT-EventQueue-0" Java stack information for the threads listed above: =================================================== "AWT-EventQueue-0": at sun.awt.motif.AWTLockAccess.awtLock(Native Method) at sun.awt.motif.MToolkitThreadBlockedHandler.lock(MToolkitThreadBlockedHandler.java:23) at sun.awt.datatransfer.DataTransferer.setBlockedMode(DataTransferer.java:1861) at sun.awt.motif.X11Selection.getSelectionOwnership(X11Selection.java:116) at sun.awt.motif.X11Clipboard.setContentsNative(X11Clipboard.java:42) at sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:62) - locked <0x42b24220> (a sun.awt.motif.X11Clipboard) at SystemClipboardbOwner.setClipboardContents(SystemClipboard2ProcTest.java:181) at SystemClipboardbOwner.lostOwnership(SystemClipboard2ProcTest.java:121) at sun.awt.datatransfer.SunClipboard$1.run(SunClipboard.java:156) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:448) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) at java.awt.EventDispatchThread.run(EventDispatchThread.java:99) "AWT-Motif": at sun.awt.datatransfer.SunClipboard.lostOwnershipLater(SunClipboard.java:124) - waiting to lock <0x42b24220> (a sun.awt.motif.X11Clipboard) at sun.awt.datatransfer.SunClipboard.lostOwnershipImpl(SunClipboard.java:106) at sun.awt.motif.X11Clipboard.lostSelectionOwnership(X11Clipboard.java:56) at sun.awt.motif.X11Selection.lostSelectionOwnership(X11Selection.java:124) at sun.awt.motif.MToolkit.run(Native Method) at java.lang.Thread.run(Thread.java:536) Found 1 deadlock. ------------------------------------------------------------------------------------------------- This deadlock is a regression introduced with the fix for 4668508. The toolkit thread owns the AWT_LOCK and tries to acquire the lock on the X11Clipboard instance. The java event dispatch thread owns the lock on the X11Clipboard instance and tries to acquire AWT_LOCK. ###@###.### 2002-06-06 ======================================================================
06-06-2002

SUGGESTED FIX Name: agR10216 Date: 05/31/2002 Wait until all desired calls of lostOwnership() are performed. Also we make test passing if there are some problems with data transfer. --- SystemClipboard2ProcTest.java Thu May 30 13:47:55 2002 *************** *** 88,93 **** --- 88,95 ---- class SystemClipboardbOwner implements ClipboardOwner { static boolean failed; + private static final Object LOCK = new Object(); + private static final int CHAIN_LENGTH = 5; private final static Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); *************** *** 100,110 **** System.err.println(id + " lost clipboard ownership"); Transferable t = getClipboardContents(cb, null); ! String msg = null; try { msg = (String)t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { ! System.err.println(id + " can't getTransferData: " + e); } System.err.println(id + " Clipboard.getContents(): " + msg); if ( ! msg.equals( "" + (m+1) ) ) { --- 102,113 ---- System.err.println(id + " lost clipboard ownership"); Transferable t = getClipboardContents(cb, null); ! // for test passing if t.getTransferData() will throw an exception ! String msg = "" + (m+1); try { msg = (String)t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { ! System.err.println(id + " can't getTransferData: " + e); } System.err.println(id + " Clipboard.getContents(): " + msg); if ( ! msg.equals( "" + (m+1) ) ) { *************** *** 117,128 **** System.err.println(id + " Clipboard.setContents(): " + m); setClipboardContents(cb, new StringSelection(m + ""), this); } } public static void run() throws IOException { SystemClipboardbOwner cbo1 = new SystemClipboardbOwner(0); System.err.println(cbo1.m + " Clipboard.setContents(): " + cbo1.m); ! clipboard.setContents(new StringSelection(cbo1.m + ""), cbo1); String javaPath = System.getProperty("java.home", ""); --- 120,137 ---- System.err.println(id + " Clipboard.setContents(): " + m); setClipboardContents(cb, new StringSelection(m + ""), this); } + if (m >= CHAIN_LENGTH) { + synchronized (LOCK) { + LOCK.notifyAll(); + } + } } public static void run() throws IOException { SystemClipboardbOwner cbo1 = new SystemClipboardbOwner(0); System.err.println(cbo1.m + " Clipboard.setContents(): " + cbo1.m); ! setClipboardContents(clipboard, new StringSelection(cbo1.m + ""), ! cbo1); String javaPath = System.getProperty("java.home", ""); *************** *** 152,161 **** } ! public static void main(String[] args) { SystemClipboardbOwner cbo2 = new SystemClipboardbOwner(1); System.err.println(cbo2.m + " Clipboard.setContents(): " + cbo2.m); ! clipboard.setContents(new StringSelection(cbo2.m + ""), cbo2); } --- 161,174 ---- } ! public static void main(String[] args) throws InterruptedException { SystemClipboardbOwner cbo2 = new SystemClipboardbOwner(1); System.err.println(cbo2.m + " Clipboard.setContents(): " + cbo2.m); ! synchronized (LOCK) { ! setClipboardContents(clipboard, new StringSelection(cbo2.m + ""), ! cbo2); ! LOCK.wait(); ! } } ###@###.### 2002-05-30 ====================================================================== Name: dsR10078 Date: 06/06/2002 Do not try to synchronize on the X11Clipboard instance on the toolkit thread. Instead, perform all the necessary modifications to X11Clipboard state the on the event dispatch thread. Additional modification is needed to improve the fix for 4668508: if setContents is called from the disposed AppContext, the fix won't work. The modification is to throw IllegalStateException in this case. Another modification is not to cleanup the native context on the toolkit thread just after we received the notification that the selection ownership is lost, but delay it until the X11Clipboard references to the current contents and owner are cleared on the event dispatch thread. This will keep X11Clipboard state and native context in sync. ###@###.### 2002-06-06 ======================================================================
06-06-2002