Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 133037

Summary: [GTK] GP when creating TreeColumn and TreeItem in MeasureItem callback
Product: [Eclipse Project] Platform Reporter: Grant Gayed <grant_gayed>
Component: SWTAssignee: Eric Williams <ericwill>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, ericwill
Version: 3.2Keywords: triaged
Target Milestone: 4.8   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Grant Gayed CLA 2006-03-23 13:05:03 EST
I know this isn't the intended use of MeasureItem callbacks, but a GP is harsh; run the snippet below, and you'll get the spew at the bottom:

public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setBounds(10, 10, 200, 200);
	final Tree tree = new Tree(shell, SWT.NONE);
	tree.setBounds(10,10,150,150);
	tree.addListener(SWT.MeasureItem, new Listener() {
		public void handleEvent(Event event) {
			new TreeColumn(tree, SWT.NONE).setWidth(100);
			new TreeItem(tree, SWT.NONE);
		}
	});
	new TreeItem(tree, SWT.NONE);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}


(SWT:10140): Gtk-CRITICAL **: file gtktreestore.c: line 639 (gtk_tree_store_get_value): assertion `iter->stamp == GTK_TREE_STORE (tree_model)->stamp' failed

(SWT:10140): GLib-GObject-CRITICAL **: file gobject.c: line 1239 (g_object_set_property): assertion `G_IS_VALUE (value)' failed

(SWT:10140): GLib-GObject-CRITICAL **: file gvalue.c: line 149 (g_value_unset): assertion `G_IS_VALUE (value)' failed

(SWT:10140): Gtk-CRITICAL **: file gtktreestore.c: line 639 (gtk_tree_store_get_value): assertion `iter->stamp == GTK_TREE_STORE (tree_model)->stamp' failed

(SWT:10140): GLib-GObject-WARNING **: gtype.c:3350: type id `0' is invalid

(SWT:10140): GLib-GObject-WARNING **: can't peek value table for type `<invalid>' which is not currently referenced
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0x002c409b, pid=10140, tid=3086882496
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_01-b08 mixed mode)
# Problematic frame:
# C  [libgtk-x11-2.0.so.0+0x1c309b]  gtk_tree_model_get_valist+0xbe
#
# An error report file with more information is saved as hs_err_pid10140.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Comment 1 Silenio Quarti CLA 2006-03-23 14:08:18 EST
Note that the testcase would loop forever if it did not GPed.
Comment 2 Eric Williams CLA 2016-08-17 11:20:32 EDT
This is still reproducible for me, assigning to Ian.
Comment 3 Alexander Kurtakov CLA 2017-05-23 03:19:43 EDT
Move out of 4.7 and reassign to Eric.
Comment 4 Eric Williams CLA 2017-05-25 14:46:12 EDT
Some initial observations:

-removing the "new TreeItem(tree, SWT.NONE);" call before shell.open() does not cause a crash
-it seems the crash finally happens in gtk_tree_model_get(), though many warnings are printed before that.
Comment 5 Eric Williams CLA 2017-05-25 15:42:16 EDT
(In reply to Eric Williams from comment #4)
> Some initial observations:
> 
> -removing the "new TreeItem(tree, SWT.NONE);" call before shell.open() does
> not cause a crash
> -it seems the crash finally happens in gtk_tree_model_get(), though many
> warnings are printed before that.

Alternatively: just commenting out the "new TreeColumn(tree, SWT.NONE).setWidth(100);" inside the handleEvent() method of the snippet prevents the crash as well.

The crash seems to happen in Tree.getId(), where the iter being passed to GTK is invalid. My guess is that the columns being created in the event handler aren't being created properly and those the iter is wrong or invalid.

I'll continue to investigate.
Comment 6 Eric Williams CLA 2017-06-28 15:46:37 EDT
(In reply to Eric Williams from comment #5)
> 
> Alternatively: just commenting out the "new TreeColumn(tree,
> SWT.NONE).setWidth(100);" inside the handleEvent() method of the snippet
> prevents the crash as well.
> 
> The crash seems to happen in Tree.getId(), where the iter being passed to
> GTK is invalid. My guess is that the columns being created in the event
> handler aren't being created properly and those the iter is wrong or invalid.
> 
> I'll continue to investigate.

I've investigated this bug further with no real leads. Since this has no applicable use case, I'm going to go ahead and close this bug. If someone has a practical use case for this issue we can re-open it and investigate further.