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

Bug 324155

Summary: Eclipse crash at quit when modal dialog opened
Product: [Eclipse Project] Platform Reporter: Zhi Guo Yang <yangzg>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact: Lakshmi P Shanmugam <lshanmug>
Severity: blocker    
Priority: P3 CC: kleind, lshanmug, mukund, pwebster, raji, remy.suen, skovatch
Version: 3.5.2   
Target Milestone: 3.7 M6   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Eclipse Crash log file
none
fix
none
patch for 3.6.2 none

Description Zhi Guo Yang CLA 2010-08-31 21:57:08 EDT
Build Identifier: eclipse-SDK-3.5.2-macosx-carbon 32 bit (Build id:M20100211-1343) 

Process:         eclipse [47963]
Path:            /Users/notes/Downloads/eclipse-SDK-3.5.2-macosx-carbon/Eclipse.app/Contents/MacOS/eclipse
Identifier:      org.eclipse.eclipse
Version:         3.5 (3.5)
Code Type:       X86 (Native)
Parent Process:  launchd [114]

Date/Time:       2010-09-01 09:47:29.016 +0800
OS Version:      Mac OS X 10.6.4 (10F569)
Report Version:  6

Interval Since Last Report:          331914 sec
Crashes Since Last Report:           24
Per-App Interval Since Last Report:  578 sec
Per-App Crashes Since Last Report:   5
Anonymous UUID:                      B09C1AE0-E88B-45A9-8C19-F524ECEECD23

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:

Java information:
 Exception type: Bus Error (0xa) at pc=000000001190c33f

 Java VM: Java HotSpot(TM) Client VM (16.3-b01-279 mixed mode macosx-x86)

Current thread (0000000012001000):  JavaThread "main" [_thread_in_vm, id=-1609112320, stack(00000000bf800000,00000000c0000000)]
Stack: [00000000bf800000,00000000c0000000]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.eclipse.swt.internal.carbon.OS.NavDialogRun(I)I+0
j  org.eclipse.swt.widgets.FileDialog.open()Ljava/lang/String;+674
j  org.eclipse.ui.internal.ide.actions.OpenLocalFileAction.run()V+36
j  org.eclipse.ui.internal.ide.actions.OpenLocalFileAction.run(Lorg/eclipse/jface/action/IAction;)V+1
j  org.eclipse.ui.internal.PluginAction.runWithEvent(Lorg/eclipse/swt/widgets/Event;)V+110
j  org.eclipse.ui.internal.WWinPluginAction.runWithEvent(Lorg/eclipse/swt/widgets/Event;)V+9
j  org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(Lorg/eclipse/swt/widgets/Event;Z)V+354
j  org.eclipse.jface.action.ActionContributionItem.access$2(Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event;Z)V+3
j  org.eclipse.jface.action.ActionContributionItem$5.handleEvent(Lorg/eclipse/swt/widgets/Event;)V+60
J  org.eclipse.swt.widgets.EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;)V
j  org.eclipse.swt.widgets.Widget.sendEvent(Lorg/eclipse/swt/widgets/Event;)V+25
j  org.eclipse.swt.widgets.Widget.sendEvent(ILorg/eclipse/swt/widgets/Event;Z)V+73
j  org.eclipse.swt.widgets.Widget.sendEvent(ILorg/eclipse/swt/widgets/Event;)V+4
j  org.eclipse.swt.widgets.Widget.notifyListeners(ILorg/eclipse/swt/widgets/Event;)V+19
j  org.eclipse.swt.widgets.Display.runDeferredEvents()Z+96
j  org.eclipse.swt.widgets.Display.readAndDispatch()Z+103
j  org.eclipse.ui.internal.Workbench.runEventLoop(Lorg/eclipse/jface/window/Window$IExceptionHandler;Lorg/eclipse/swt/widgets/Display;)V+9
j  org.eclipse.ui.internal.Workbench.runUI()I+393
j  org.eclipse.ui.internal.Workbench.access$4(Lorg/eclipse/ui/internal/Workbench;)I+1
j  org.eclipse.ui.internal.Workbench$5.run()V+55
j  org.eclipse.core.databinding.observable.Realm.runWithDefault(Lorg/eclipse/core/databinding/observable/Realm;Ljava/lang/Runnable;)V+12
j  org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+18
j  org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j  org.eclipse.ui.internal.ide.application.IDEApplication.start(Lorg/eclipse/equinox/app/IApplicationContext;)Ljava/lang/Object;+84
j  org.eclipse.equinox.internal.app.EclipseAppHandle.run(Ljava/lang/Object;)Ljava/lang/Object;+135
j  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Ljava/lang/Object;)Ljava/lang/Object;+103
j  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ljava/lang/Object;)Ljava/lang/Object;+29
j  org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+149
j  org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+183
v  ~StubRoutines::call_stub
j  sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j  sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j  org.eclipse.equinox.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+211
j  org.eclipse.equinox.launcher.Main.basicRun([Ljava/lang/String;)V+114
j  org.eclipse.equinox.launcher.Main.run([Ljava/lang/String;)I+4
v  ~StubRoutines::call_stub

Java Threads: ( => current thread )
  0000000012aa3000 JavaThread "[ThreadPool Manager] - Idle Thread" daemon [_thread_blocked, id=-1312432128, stack(00000000b1b5e000,00000000b1c5e000)]
  000000001298c000 JavaThread "Worker-4" [_thread_blocked, id=-1316659200, stack(00000000b1756000,00000000b1856000)]
  000000001209b000 JavaThread "Worker-3" [_thread_blocked, id=-1318772736, stack(00000000b1552000,00000000b1652000)]
  0000000012197400 JavaThread "Java indexing" daemon [_thread_blocked, id=-1317715968, stack(00000000b1654000,00000000b1754000)]
  0000000012127800 JavaThread "[Timer] - Main Queue Handler" daemon [_thread_blocked, id=-1320886272, stack(00000000b134e000,00000000b144e000)]
  000000001289b400 JavaThread "Framework Event Dispatcher" daemon [_thread_blocked, id=-1324171264, stack(00000000b102c000,00000000b112c000)]
  00000000120e5800 JavaThread "Start Level Event Dispatcher" daemon [_thread_blocked, id=-1325228032, stack(00000000b0f2a000,00000000b102a000)]
  00000000120e5000 JavaThread "State Data Manager" daemon [_thread_blocked, id=-1326284800, stack(00000000b0e28000,00000000b0f28000)]
  00000000120c4c00 JavaThread "Poller SunPKCS11-Darwin" daemon [_thread_blocked, id=-1327378432, stack(00000000b0d1d000,00000000b0e1d000)]
  0000000012050c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=-1329491968, stack(00000000b0b19000,00000000b0c19000)]
  000000001286a400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=-1330548736, stack(00000000b0a17000,00000000b0b17000)]
  000000001204f800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=-1331605504, stack(00000000b0915000,00000000b0a15000)]
  0000000012869800 JavaThread "Surrogate Locker Thread (CMS)" daemon [_thread_blocked, id=-1332662272, stack(00000000b0813000,00000000b0913000)]
  0000000012866400 JavaThread "Finalizer" daemon [_thread_blocked, id=-1333719040, stack(00000000b0711000,00000000b0811000)]
  0000000012043c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=-1334775808, stack(00000000b060f000,00000000b070f000)]
=>0000000012001000 JavaThread "main" [_thread_in_vm, id=-1609112320, stack(00000000bf800000,00000000c0000000)]
Other Threads:
  0000000012042400 VMThread [stack: 00000000b050d000,00000000b060d000] [id=-1335832576]
  000000001205a000 WatcherThread [stack: 00000000b0c1b000,00000000b0d1b000] [id=-1328435200]

VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None

Heap
 par new generation   total 14784K, used 5164K [0000000015010000, 0000000016010000, 0000000017010000)
  eden space 13184K,  33% used [0000000015010000, 0000000015466ef8, 0000000015cf0000)
  from space 1600K,  45% used [0000000015cf0000, 0000000015da4390, 0000000015e80000)
  to   space 1600K,   0% used [0000000015e80000, 0000000015e80000, 0000000016010000)
 concurrent mark-sweep generation total 51808K, used 32938K [0000000017010000, 000000001a2a8000, 0000000025010000)
 concurrent-mark-sweep perm gen total 68804K, used 41834K [0000000025010000, 0000000029341000, 0000000035010000)

Virtual Machine Arguments:
JVM Args: -Xms40m -Xmx256m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -XX:MaxPermSize=256m 
Java Command: <unknown>
Launcher Type: generic
Physical Memory: Page Size = 4k, Total = 1792M, Free = 25M


Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libjvm.dylib                  	0x1190c33f JVM_Socket + 5647
1   libswt-carbon-3557.jnilib     	0x3a15cf40 callback + 855
2   ???                           	0x3a1da458 0 + 975021144
3   com.apple.HIToolbox           	0x95b39f2f DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1567
4   com.apple.HIToolbox           	0x95b391f6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411
5   com.apple.HIToolbox           	0x95b5b9bb SendEventToEventTarget + 52
6   com.apple.HIToolbox           	0x95b6d57b ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 1417
7   com.apple.HIToolbox           	0x95b3a380 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 2672
8   com.apple.HIToolbox           	0x95b391f6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411
9   com.apple.HIToolbox           	0x95b5b9bb SendEventToEventTarget + 52
10  com.apple.HIToolbox           	0x95ce4cc3 ToolboxEventDispatcher + 86
11  com.apple.HIToolbox           	0x95ce4cfe HLTBEventDispatcher + 17
12  com.apple.HIToolbox           	0x95ce523c _RunAppModalLoop + 158
13  com.apple.HIToolbox           	0x95ce5697 RunAppModalLoopForWindow + 194
14  com.apple.AppKit              	0x921e4a6a -[NSApplication _realDoModalLoop:peek:] + 961
15  com.apple.AppKit              	0x921e40f5 -[NSApplication runModalForWindow:] + 273
16  com.apple.AppKit              	0x92478107 -[NSSavePanel runModal] + 420
17  com.apple.AppKit              	0x92652643 -[NSNavOpenPanel run] + 141
18  com.apple.AppKit              	0x926541f7 _NSNavDialogRun + 223
19  libswt-pi-carbon-3557.jnilib  	0x3a177484 Java_org_eclipse_swt_internal_carbon_OS_NavDialogRun + 24
20  ???                           	0x1300b959 0 + 318814553
21  ???                           	0x13003ed5 0 + 318783189
22  ???                           	0x13003f17 0 + 318783255
23  ???                           	0x13003db1 0 + 318782897
24  ???                           	0x1300428d 0 + 318784141
25  ???                           	0x13003db1 0 + 318782897
26  ???                           	0x1300428d 0 + 318784141
27  ???                           	0x13003db1 0 + 318782897
28  ???                           	0x13003db1 0 + 318782897
29  ???                           	0x1322ad84 0 + 321039748
30  ???                           	0x13003db1 0 + 318782897
31  ???                           	0x13003db1 0 + 318782897
32  ???                           	0x13003db1 0 + 318782897
33  ???                           	0x13003db1 0 + 318782897
34  ???                           	0x13003db1 0 + 318782897
35  ???                           	0x13003fdd 0 + 318783453
36  ???                           	0x13003fdd 0 + 318783453
37  ???                           	0x13003db1 0 + 318782897
38  ???                           	0x13003ed5 0 + 318783189
39  ???                           	0x13003ed5 0 + 318783189
40  ???                           	0x1300428d 0 + 318784141
41  ???                           	0x13003db1 0 + 318782897
42  ???                           	0x13003ed5 0 + 318783189
43  ???                           	0x13003ed5 0 + 318783189
44  ???                           	0x130043f3 0 + 318784499
45  ???                           	0x130043f3 0 + 318784499
46  ???                           	0x13003f17 0 + 318783255
47  ???                           	0x13003f17 0 + 318783255
48  ???                           	0x13003f17 0 + 318783255
49  ???                           	0x130012d3 0 + 318771923
50  libjvm.dylib                  	0x118a3500 JVM_Lseek + 139952
51  libjvm.dylib                  	0x118a32a6 JVM_Lseek + 139350
52  libjvm.dylib                  	0x118a3276 JVM_Lseek + 139302
53  libjvm.dylib                  	0x118c6008 JVM_NewInstanceFromConstructor + 3896
54  libjvm.dylib                  	0x118c7bfe JVM_InvokeMethod + 1342
55  libjvm.dylib                  	0x118c78b2 JVM_InvokeMethod + 498
56  libjvmlinkage.dylib           	0x000ca72f JVM_InvokeMethod + 79
57  libjava.jnilib                	0x00716132 Java_sun_reflect_NativeMethodAccessorImpl_invoke0 + 38
58  ???                           	0x1300b959 0 + 318814553
59  ???                           	0x13003f17 0 + 318783255
60  ???                           	0x13003f17 0 + 318783255
61  ???                           	0x130043f3 0 + 318784499
62  ???                           	0x13003f17 0 + 318783255
63  ???                           	0x13003db1 0 + 318782897
64  ???                           	0x13003db1 0 + 318782897
65  ???                           	0x130012d3 0 + 318771923
66  libjvm.dylib                  	0x118a3500 JVM_Lseek + 139952
67  libjvm.dylib                  	0x118a32a6 JVM_Lseek + 139350
68  libjvm.dylib                  	0x118a3276 JVM_Lseek + 139302
69  libjvm.dylib                  	0x118b9060 JVM_MonitorWait + 15104
70  libjvm.dylib                  	0x11906f84 JVM_EnableCompiler + 8596
71  eclipse_1206.so               	0x0006b7d6 startJavaJNI + 1795
72  eclipse_1206.so               	0x0006a1c3 startJavaVM + 120
73  eclipse_1206.so               	0x000692e9 run + 4768
74  org.eclipse.eclipse           	0x000024aa original_main + 1782
75  org.eclipse.eclipse           	0x00002b96 main + 1517
76  org.eclipse.eclipse           	0x00001c10 _start + 210
77  org.eclipse.eclipse           	0x00001b3d start + 41

Reproducible: Always

Steps to Reproduce:
1. Launch Eclipse.app;
2. Select menu "File" -> "Open File...", then open the "Open File" model dialog;
3. Go to the Eclipse icon in Desktop Dock and right click and click on Quit in popup menubar. ( or use Control + mouse left click on Eclipes Dock icon and select Quit in popup menubar)  ;
4. Eclipse app got crash.
Comment 1 Zhi Guo Yang CLA 2010-08-31 22:06:14 EDT
Created attachment 177904 [details]
Eclipse Crash log file

Eclipse Crash log file
Comment 2 Scott Kovatch CLA 2010-09-01 13:21:23 EDT
On 3.6 Carbon we don't crash, but you're left with the file chooser dialog open. Canceling that gracefully quits Eclipse. In Cocoa the quit command cancels the file dialog first.
Comment 3 Scott Kovatch CLA 2010-09-08 14:21:12 EDT
Moving to Silenio, since it's Carbon.
Comment 4 Silenio Quarti CLA 2010-12-22 11:59:45 EST
I believe this is already fixed in 3.6.2. I cannot reproduce the problem with the following build. Please try it out and let me know if you still can reproduce it.

http://download.eclipse.org/eclipse/downloads/drops/M20101222-0800/index.php
Comment 5 mukundan desikan CLA 2011-02-18 12:27:02 EST
Silenio 

Can you please confirm if this is fixed with SWT 3.6.2 . We are currently using the RC1 build .
Comment 6 Lakshmi P Shanmugam CLA 2011-02-22 07:05:37 EST
I tried the scenario with 3.6.2 RC1 build and cannot reproduce the crash. But, the file dialog is left behind and has to be canceled.
Comment 7 Lakshmi P Shanmugam CLA 2011-02-22 07:12:22 EST
Ok, I tried again. In the same scenario, after quiting eclipse, the file dialog was left behind. I didn't cancel it and left it as it is. It crashes after say 1-2 mins.
Comment 8 David Klein CLA 2011-02-24 15:35:02 EST
Since this can still be recreated, am requesting that this bug be re-opened.
Comment 9 David Klein CLA 2011-03-01 14:36:55 EST
Is this bug related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=336957 ?
Comment 10 Silenio Quarti CLA 2011-03-02 12:25:46 EST
Lakshmi, please investigate this bug further and see if you can find a solution.

I am still not able to reproduce it. I left the FileDialog up for a long time. Eclipse did not crash and as soon as I press the cancel button, eclipse exists normally.
Comment 11 Silenio Quarti CLA 2011-03-02 13:06:38 EST
(In reply to comment #9)
> Is this bug related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=336957 ?

It is hard to tell. The stacks are not similar.
Comment 12 Lakshmi P Shanmugam CLA 2011-03-02 15:27:47 EST
Here is a simple snippet to reproduce the problem. After quitting with modal dialog open, try to click on another window/application to see the crash happen. Invalid memory access is printed in the console.

import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Bug_324155 {
	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		Button button = new Button(shell, SWT.PUSH);
		button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
		button.setText("open file dialog");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				FileDialog fd = new FileDialog(shell, SWT.OPEN);
				fd.open();
			}
		});
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 13 Silenio Quarti CLA 2011-03-02 16:07:44 EST
Thanks Lakshmi, I can reproduce the problem with your snippet.

The problem happens because you are leaving event handlers attached and disposing their callback (appleEventCallback, commandCallback, etc). I am working on a fix.
Comment 14 Silenio Quarti CLA 2011-03-02 16:33:06 EST
Created attachment 190205 [details]
fix

I released this patch to HEAD. Lakshmi, please try it out.
Comment 15 Silenio Quarti CLA 2011-03-02 16:37:51 EST
Fixed > 20110302.
Comment 16 Remy Suen CLA 2011-03-02 17:03:34 EST
(In reply to comment #14)
> Created attachment 190205 [details]
> fix
> 
> I released this patch to HEAD. Lakshmi, please try it out.

In case anyone was confused as I was when looking at the patch, the print statements have been removed.
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt/Eclipse%20SWT/carbon/org/eclipse/swt/widgets/Display.java?r1=1.348&r2=1.349
Comment 17 David Klein CLA 2011-03-03 12:41:21 EST
Can we get a patch for 3.6.2 (or will this patch already apply to 3.6.2)?
Comment 18 Silenio Quarti CLA 2011-03-03 14:53:12 EST
Created attachment 190304 [details]
patch for 3.6.2

This is the patch for the 3.6.2 branch. Note that it contains changes in the native code, so you need new SWT libraries.