Bug 562233 - JVM crash after throwing exception from SWT.Dispose for Shell
Summary: JVM crash after throwing exception from SWT.Dispose for Shell
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.15   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.21 M1   Edit
Assignee: Alexandr Miloslavskiy CLA
QA Contact: Niraj Modi CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-16 15:15 EDT by Alexandr Miloslavskiy CLA
Modified: 2021-07-08 09:25 EDT (History)
5 users (show)

See Also:


Attachments
Repro snippet (1.42 KB, text/plain)
2020-04-16 16:07 EDT, Alexandr Miloslavskiy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr Miloslavskiy CLA 2020-04-16 15:15:52 EDT
Typical crash log:

----------------
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libgdk-3.so.0+0x45420]  gdk_window_get_frame_extents+0x0

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.eclipse.swt.internal.gtk.GDK._gdk_window_get_root_origin(J[I[I)V+0
J 30379 c1 org.eclipse.swt.widgets.Shell.getBoundsInPixels()Lorg/eclipse/swt/graphics/Rectangle; (143 bytes) @ 0x00007fbfb7ae3484 [0x00007fbfb7ae2fa0+0x00000000000004e4]
J 35492 c1 org.eclipse.swt.widgets.Shell.setEnabled(Z)V (320 bytes) @ 0x00007fbfb74ed444 [0x00007fbfb74ec720+0x0000000000000d24]
<...>
J 40811 c2 org.eclipse.swt.widgets.EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;)V (584 bytes) @ 0x00007fbfbfa9a684 [0x00007fbfbfa9a560+0x0000000000000124]
J 12270 c2 org.eclipse.swt.widgets.Display.runDeferredEvents()Z (109 bytes) @ 0x00007fbfbee98fc8 [0x00007fbfbee98ba0+0x0000000000000428]
J 12304 c2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (73 bytes) @ 0x00007fbfbeea7f2c [0x00007fbfbeea7a80+0x00000000000004ac]
<...>

siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000018
----------------

I will provide more information soon.
Comment 1 Alexandr Miloslavskiy CLA 2020-04-16 16:07:58 EDT
Created attachment 282482 [details]
Repro snippet

The problem here is:
1) When Exception occurs, it falls through into native-java glue `callback()`
2) `callback()` returns 0 to GTK.
3) For `delete-event`, 0 means "proceed with other handlers".
4) Default handler destroys Shell, but SWT is not aware of that.
5) Trying to access Shell causes use of already freed pointer.
Comment 2 Eclipse Genie CLA 2021-06-17 10:58:28 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/182120
Comment 3 Eclipse Genie CLA 2021-06-21 17:00:05 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/182320
Comment 5 Niraj Modi CLA 2021-06-30 03:14:00 EDT
(In reply to Eclipse Genie from comment #4)
> Gerrit change
> https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/182320 was
> merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=aec661287354ebd74f607d83b584b162c8047520

Thanks Alexandr for this fix, it should definitely added to stability of Eclipse/SWT based applications.

Please raise separate bug to cover below mentioned part copying the patch comment:
"This patch only insulates some paths while others (such as various
'Widget.disposeChildren()') remain for future patches."

Resolving now.
Comment 6 Alexandr Miloslavskiy CLA 2021-06-30 03:44:06 EDT
Thanks for reviewing!

> Please raise separate bug to cover below mentioned part

Created Bug 574560
Comment 7 Niraj Modi CLA 2021-07-08 09:25:01 EDT
Verified in Build id: I20210707-1800