Description
Describe the bug
Virtual Tree
widget crashes JVM (through GTK3) when setting Image
onto TreeItem
in Listener
to SWT.SetData
.
This is a continuation of https://bugs.eclipse.org/bugs/show_bug.cgi?id=573090.
--------------- T H R E A D ---------------
Current thread (0x00007ffa500284a0): JavaThread "main" [_thread_in_native, id=112372, stack(0x00007ffa57900000,0x00007ffa57a00000)]
Stack: [0x00007ffa57900000,0x00007ffa57a00000], sp=0x00007ffa579fc318, free space=1008k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libgobject-2.0.so.0+0x3b251] g_type_check_instance_is_fundamentally_a+0x11
C [libswt-pi3-gtk-4958r2.so+0x4b609] Java_org_eclipse_swt_internal_gtk_OS_g_1object_1set__J_3BJJ+0x4a
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 11988 org.eclipse.swt.internal.gtk.OS.g_object_set(J[BJJ)V (0 bytes) @ 0x00007ffa491c5883 [0x00007ffa491c5820+0x0000000000000063]
J 10921 c1 org.eclipse.swt.widgets.Tree.cellDataProc(JJJJJ)J (486 bytes) @ 0x00007ffa419b8bf4 [0x00007ffa419b81e0+0x0000000000000a14]
J 10920 c1 org.eclipse.swt.widgets.Display.cellDataProc(JJJJJ)J (29 bytes) @ 0x00007ffa41f4ac5c [0x00007ffa41f4aa60+0x00000000000001fc]
v ~StubRoutines::call_stub
J 11619 org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(Z)Z (0 bytes) @ 0x00007ffa49380e69 [0x00007ffa49380e20+0x0000000000000049]
J 11623 c1 org.eclipse.swt.widgets.Display.readAndDispatch()Z (88 bytes) @ 0x00007ffa423e622c [0x00007ffa423e6060+0x00000000000001cc]
To Reproduce
package swt_tree_crash;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
public class Main {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Tree tree = new Tree(shell, SWT.VIRTUAL);
tree.addListener(SWT.SetData, new Listener() {
public void handleEvent(final Event e) {
TreeItem item = (TreeItem)e.item;
item.setText(0, "A");
item.setImage(new Image(display, 20, 20)); // <-- this is the critical line!
}
});
tree.setItemCount(1);
shell.setSize(400, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Expected behavior
The application always shows a window with a tree widget in it, containing one item, with a small white icon.
Screenshots
Not applicable.
Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS
- Additional OS info (e.g. OS version, Linux Desktop, etc)
Operating System: Fedora Linux 38
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Kernel Version: 6.2.15-300.fc38.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 3800X 8-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: AMD Radeon RX 550 Series
org.eclipse.swt.internal.gtk.version=3.24.37
- JRE/JDK version
JRE version: OpenJDK Runtime Environment Temurin-17.0.7+7 (17.0.7+7) (build 17.0.7+7)
Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (17.0.7+7, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
Version since
Tested on Eclipse 4.27 (SWT 4.958).
Workaround (or) Additional context
The crash doesn't always happen, but fairly often.
Removing the TreeItem.setImage
call avoids the crash entirely.