Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTK4] gtk_shortcut_controller_remove_shortcut crash when using Eclipse #346

Closed
joel-majano opened this issue Aug 25, 2022 · 1 comment
Closed
Labels
gtk4 GTK4 issues Linux/GTK Happens on Linux

Comments

@joel-majano
Copy link
Contributor

joel-majano commented Aug 25, 2022

After opening a file in GTK4 and moving around in the IDE a crash happens in gtk_shortcut_controller_remove_shortcut.

Here is the log: hs_err_pid174210.log

Environment: GTK 4.6.5, Fedora 36, Wayland

Tracked in #228

@lshanmug lshanmug added Linux/GTK Happens on Linux gtk4 GTK4 issues labels Aug 29, 2022
@mbooth101
Copy link
Member

Hmm, I believe I reproduced this, with the following snippet:

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setText("Snippet 29");
		Menu bar = new Menu(shell, SWT.BAR);
		shell.setMenuBar(bar);
		MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
		fileItem.setText("&File");
		Menu submenu = new Menu(shell, SWT.DROP_DOWN);
		fileItem.setMenu(submenu);
		MenuItem addItem = new MenuItem(submenu, SWT.PUSH);
		MenuItem removeItem = new MenuItem(submenu, SWT.PUSH);
		addItem.addListener(SWT.Selection, e -> {
			System.out.println("Adding Accelerators");
			addItem.setText("&Add Accelerators\tCtrl+A");
			addItem.setAccelerator(SWT.MOD1 | 'A');
			removeItem.setText("&Remove Accelerators\tCtrl+R");
			removeItem.setAccelerator(SWT.MOD1 | 'R');
		});
		removeItem.addListener(SWT.Selection, e -> {
			System.out.println("Removing Accelerators");
			addItem.setText("&Add Accelerators");
			addItem.setAccelerator(0);
			removeItem.setText("&Remove Accelerators");
			removeItem.setAccelerator(0);
		});
		addItem.setText("&Add Accelerators\tCtrl+A");
		addItem.setAccelerator(SWT.MOD1 | 'A');
		removeItem.setText("&Remove Accelerators\tCtrl+R");
		removeItem.setAccelerator(SWT.MOD1 | 'R');
		shell.setSize(200, 200);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

I always get GTK-CRITICALs like this:

(SWT:2950764): Gtk-CRITICAL **: 23:24:32.885: gtk_shortcut_controller_remove_shortcut: assertion 'GTK_IS_SHORTCUT (shortcut)' failed

(SWT:2950764): Gtk-CRITICAL **: 23:24:32.886: gtk_shortcut_controller_remove_shortcut: assertion 'GTK_IS_SHORTCUT (shortcut)' failed

And occasionally, I see it crash like this:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f0f6e413053, pid=2955750, tid=2955757
#
# JRE version: OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.fc36) (11.0.18+10) (build 11.0.18+10)
# Java VM: OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.fc36) (11.0.18+10, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libgtk-4.so.1+0x213053]  gtk_shortcut_controller_remove_shortcut+0x53
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/mbooth/workspace-swt/eclipse.platform.swt/examples/org.eclipse.swt.snippets/core.2955750)
#
# If you would like to submit a bug report, please visit:
#   https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=java-11-openjdk&version=36
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  S U M M A R Y ------------

Command Line: -Djava.library.path=/home/mbooth/workspace-swt/eclipse.platform.swt.binaries/bundles/org.eclipse.swt.gtk.linux.x86_64 -Dfile.encoding=UTF-8 org.eclipse.swt.snippets.Snippet29

Host: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz, 8 cores, 31G, Fedora release 36 (Thirty Six)
Time: Sun Mar 19 23:55:43 2023 GMT elapsed time: 18.737745 seconds (0d 0h 0m 18s)

---------------  T H R E A D  ---------------

Current thread (0x00007f0fc8016000):  JavaThread "main" [_thread_in_native, id=2955757, stack(0x00007f0fced00000,0x00007f0fcee00000)]

Stack: [0x00007f0fced00000,0x00007f0fcee00000],  sp=0x00007f0fcedfe410,  free space=1017k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libgtk-4.so.1+0x213053]  gtk_shortcut_controller_remove_shortcut+0x53

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.eclipse.swt.internal.gtk4.GTK4.gtk_shortcut_controller_remove_shortcut(JJ)V+0
j  org.eclipse.swt.widgets.MenuItem.setAccelerator(I)V+39
j  org.eclipse.swt.snippets.Snippet29.lambda$0(Lorg/eclipse/swt/widgets/MenuItem;Lorg/eclipse/swt/widgets/MenuItem;Lorg/eclipse/swt/widgets/Event;)V+21
j  org.eclipse.swt.snippets.Snippet29$$Lambda$16.handleEvent(Lorg/eclipse/swt/widgets/Event;)V+9
j  org.eclipse.swt.widgets.EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;)V+243
j  org.eclipse.swt.widgets.Display.sendEvent(Lorg/eclipse/swt/widgets/EventTable;Lorg/eclipse/swt/widgets/Event;)V+12
J 250 c1 org.eclipse.swt.widgets.Display.runDeferredEvents()Z (109 bytes) @ 0x00007f0fb0be205c [0x00007f0fb0be17c0+0x000000000000089c]
J 239 c1 org.eclipse.swt.widgets.Display.readAndDispatch()Z (88 bytes) @ 0x00007f0fb0bdc40c [0x00007f0fb0bdbfe0+0x000000000000042c]
j  org.eclipse.swt.snippets.Snippet29.main([Ljava/lang/String;)V+187
v  ~StubRoutines::call_stub

siginfo: si_signo: 11 (SIGSEGV), si_code: 128 (SI_KERNEL), si_addr: 0x0000000000000000

mbooth101 added a commit to mbooth101/eclipse.platform.swt that referenced this issue Mar 20, 2023
…rtcut crash

Null the handle reference after removing the shortcut from the menu
item, to prevent it from trying to remove the shortcut more than once.

Fixes eclipse-platform#346

Signed-off-by: Mat Booth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gtk4 GTK4 issues Linux/GTK Happens on Linux
Projects
None yet
Development

No branches or pull requests

3 participants