| Summary: | Crash in SWT Carbon OS.ReceiveNextEvent / Display.trayItemProc | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Greg Smith <gregsmit> | ||||||
| Component: | SWT | Assignee: | Silenio Quarti <Silenio_Quarti> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Lakshmi P Shanmugam <lshanmug> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | kleind, mukund, skovatch | ||||||
| Version: | 3.6.1 | ||||||||
| Target Milestone: | 3.7 M6 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Greg Smith
Created attachment 188788 [details]
Apple crash report showing the result of the crash
Correction -- The crash is caused by selecting "Exit" on the tray item. So the user selects Exit on the tray item, then as the app is shutting down, the crash occurs. The version of SWT in the bug summary is wrong. It should be 3.6.1. Greg, can you change this? Also, it seems this may be related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=324155 Fixed -- sorry about that, the form that calculates that value from the build on a new seems to always set that value wrong. I have fixed it. I have not been able to reproduce the crash with this snippet. Is this app similar to yours? Do you have more details to help reproduce it? /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.snippets; /* * Tooltip example snippet: create a balloon tooltip for a tray item * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ * * @since 3.2 */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class Snippet225 { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Image image = null; final ToolTip tip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_INFORMATION); tip.setMessage("Here is a message for the user. When the message is too long it wraps. I should say something cool but nothing comes to my mind."); Tray tray = display.getSystemTray(); if (tray != null) { TrayItem item = new TrayItem(tray, SWT.NONE); image = display.getSystemImage(SWT.ICON_INFORMATION); item.setImage(image); tip.setText("Notification from a tray item"); item.setToolTip(tip); item.addListener(SWT.MenuDetect, new Listener() { public void handleEvent(Event event) { Menu m = new Menu(shell, SWT.POP_UP); MenuItem mi = new MenuItem(m, SWT.PUSH); mi.setText("Exit"); mi.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { display.dispose(); } }); m.setVisible(true); } }); } else { tip.setText("Notification from anywhere"); tip.setLocation(400, 400); } Button button = new Button (shell, SWT.PUSH); button.setText("Press for balloon tip"); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { tip.setVisible(true); } }); button.pack(); shell.setBounds(50, 50, 300, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (image != null) image.dispose(); display.dispose(); } } Hi Silenio, Our application is much larger than that, obviously, but that might be able to recreate the same situation. The crash is intermittent, and seems to be fairly rare, as we have only had it reported to us once (that I know of) in a large amount of testing. We can not recreate it at will, so its likely that you would not be able to recreate it easily either. I am able to reproduce a problem that could be related. Run the snippet, press and "hold" the left mouse button in the tray item, move the mouse down so that the menu appears and select the "Exit" menu item. This exception is printed to the console: Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to org.eclipse.swt.widgets.TrayItem at org.eclipse.swt.widgets.Display.trayItemProc(Display.java:4409) at org.eclipse.swt.internal.carbon.OS.ReceiveNextEvent(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3279) at org.eclipse.swt.widgets.Display.release(Display.java:3354) at org.eclipse.swt.graphics.Device.dispose(Device.java:206) at org.eclipse.swt.snippets.Snippet225$1$1.handleEvent(Snippet225.java:48) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1669) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1693) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1678) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1421) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3731) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3299) at org.eclipse.swt.snippets.Snippet225.main(Snippet225.java:69) The stack is the same. It is not a segmentation fault, but the JVM could crash as well since the user_data passed to trayItemProc is not a valid JNI reference. It has been deleted in TrayItem.releaseWidget(). I am going to assume this is the same problem you are seeing. Could you try these steps? Created attachment 190453 [details]
fix
This is the patch to fix the problem I described above.
I released this to HEAD. The same patch applies properly in the 3.6.2 branch, but note that there changes in the native code, so the SWT libraries have to be recompiled. Fixed > 20110304 Hi Silenio, Yes -- I think that's it. I can recreate the same stack trace in our application -- so it must be that crash itself just "sometimes" happens as you mention because of something in the JNI. Thanks much for your help. 2011/03/04 17:22:34.536 SEVERE CLPDN0021E: Exception trace follows: ::class.method=com.ibm.rcp.personality.framework.internal.RCPApplication.run() ::thread=Thread-0 ::loggername=com.ibm.rcp.personality.framework.internal java.lang.ClassCastException: java.lang.Object cannot be cast to org.eclipse.swt.widgets.TrayItem at org.eclipse.swt.widgets.Display.trayItemProc(Display.java:4335) at org.eclipse.swt.internal.carbon.OS.ReceiveNextEvent(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3220) at org.eclipse.swt.widgets.Display.release(Display.java:3295) at org.eclipse.swt.graphics.Device.dispose(Device.java:206) at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574) .......... |