Community
Participate
Working Groups
Snippet sufficient to reproduce on Ubuntu 20.04: -------- final Display display = Display.getDefault(); final Shell shell = new Shell(display); final Event e = new Event(); e.keyCode = 'a'; e.character = (char)'a'; e.type = SWT.KeyDown; e.widget = shell; display.post(e); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); -------- When it happens, there are errors on console: -------- (SWT:3222): Gdk-WARNING **: 17:20:18.309: losing last reference to undestroyed window (SWT:3222): Gdk-ERROR **: 17:20:18.310: attempted to destroy root window -------- And then JVM terminates. Sometimes it will also 100% CPU hang.
Alexander, which Eclipse version is affected? Is this a recent regression?
Investigating. I suspect Bug 518714, due to discussion in Bug 562774.
When checking out SWT just before Bug 540809, snippet does not find any problems. When checking out Bug 540809, there is the same problem as in SWT master.
(In reply to Alexandr Miloslavskiy from comment #3) > When checking out SWT just before Bug 540809, snippet does not find any > problems. > When checking out Bug 540809, there is the same problem as in SWT master. Thanks. I assume you mean https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=e00275735f8b20c92b650305ad50ef8f845d6e64, which means, the problem starts with 4.10. I can reproduce with this snippet on RHEL 7.4 / GTK 3.22 / Eclipse 4.15 too. Alexandr, do you plan to provide a patch? Here the full class to copy/paste: import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; public class Snippet { public static void main(String[] args) { final Display display = Display.getDefault(); final Shell shell = new Shell(display); final Event e = new Event(); e.keyCode = 'a'; e.character = 'a'; e.type = SWT.KeyDown; e.widget = shell; display.post(e); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }
Curious: Alexandr, how did you found this snippet? Is this reproducible somehow via "typical" IDE usage? If I see it right, the only reason it crashes is that we don't open the shell before posting the event? So how one can get such an event to not yet opened shell "in the wild"? Some automated (broken) test case?
Yes, I'm working on a patch. It seems to be less scary than it initially seemed. I understand that problem only occurs when a focused window was not found. I found it when trying to run SWT JUnit tests, namely 'Test_org_eclipse_swt_widgets_Text.test_backspaceAndDelete'. It does open a Shell, but it's not sufficient to prevent the problem, 'display.readAndDispatch()' also needs to spin enough.
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/173764
Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/173764 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=5bb5c13d73ab22d4fa7b81d7a78cbdf0fbfbcb36
Thanks for reviewing!