Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353942

Summary: [Cocoa] DND drag to table after previous drag threw exception causes SWT native code to hang
Product: [Eclipse Project] Platform Reporter: Ed Gow <elg>
Component: SWTAssignee: Lakshmi P Shanmugam <lshanmug>
Status: CLOSED DUPLICATE QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: critical    
Priority: P3 CC: eclipse.felipe, lshanmug, ned.twigg, remy.suen, Silenio_Quarti
Version: 3.7   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Code to reproduce. none

Description Ed Gow CLA 2011-08-04 17:25:19 EDT
Build Identifier: 20110615-0604

Mac only. After an exception is thrown in a drag from table to table, attempting to drag again will hang the SWT thread in loop that consumes all memory. Thread stack dump looks like this: 

"Thread-0" daemon prio=5 tid=101852000 nid=0x7fff7027d700 runnable [7fff5fbfb000]
   java.lang.Thread.State: RUNNABLE
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
	at org.eclipse.swt.widgets.Widget.mouseDownSuper(Widget.java:1025)
	at org.eclipse.swt.widgets.Table.mouseDownSuper(Table.java:1936)
	at org.eclipse.swt.widgets.Widget.mouseDown(Widget.java:1021)
	at org.eclipse.swt.widgets.Control.mouseDown(Control.java:2258)
	at org.eclipse.swt.widgets.Table.mouseDown(Table.java:1909)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
	at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:1943)
	at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2025)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5040)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4582)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:4659)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:115)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3274)
	at DNDWithExceptionExample.main(DNDWithExceptionExample.java:73)


Reproducible: Always

Steps to Reproduce:
1. Run the attached program. (You'll need SWT and SWT native jars on classpath.)
2. Drag text from left table to right table TWICE. 
3. Second drag will cause main thread to hang. 
4. Observe CPU and memory consumption in hung state.
Comment 1 Ed Gow CLA 2011-08-04 17:28:38 EDT
Created attachment 200946 [details]
Code to reproduce.

Same problem occurs in Eclipse 3.7 and 3.6.1.
Comment 2 Ed Gow CLA 2011-08-04 17:37:15 EDT
Similar, perhaps even same, problem occurs intermittently on first drag, but I cannot provide a test case to reproduce it.
Comment 3 Felipe Heidrich CLA 2011-08-05 10:34:40 EDT
when an exception happens in an event handler it has to handled *before* the event handler returns. Otherwise SWT will stop receving call ins.

Basically, if you have a expection in your code, you need to fix it.
is that the case ?
Comment 4 Ed Gow CLA 2011-08-11 17:10:51 EDT
(In reply to comment #3)
> when an exception happens in an event handler it has to handled *before* the
> event handler returns. Otherwise SWT will stop receving call ins.
> 
> Basically, if you have a expection in your code, you need to fix it.
> is that the case ?

It would be nice, though, if the UI did not lock up and consume all available system memory. The Windows version does not do that, and it upsets the Mac users when it happens. 

Also, the same symptoms happen occasionally during a drop w/o an exception. I cannot reproduce that reliably, so I submitted this test case in the hopes that fixing this one might fix both.
Comment 5 Ned Twigg CLA 2018-08-15 19:06:32 EDT
I'm seeing this exact same stacktrace in the latest SWT (4.8.0).  No exception in my case, just clicking a table intermittently causes a hang.
Comment 6 Lakshmi P Shanmugam CLA 2020-03-11 07:03:10 EDT

*** This bug has been marked as a duplicate of bug 395381 ***