GDK/X error trace trap on instantiating two separate GtkClutter.Window's
On an application I'm developing, some of our users are having GDK/X window crashes when running the application with more than one screen:
(komorebi:28464): Gdk-ERROR **: 13:51:54.150: The program 'komorebi' received an X Window System error.
This probably reflects a bug in the program.
The error was 'GLXBadDrawable'.
(Details: serial 488 error_code 160 request_code 152 (GLX) minor_code 29)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
[1] 28464 trace trap (core dumped) ./komorebi
I was then able to create this small reproduction file:
using Gdk;
public class BackgroundWindow : GtkClutter.Window {
Clutter.Text textLabel;
public BackgroundWindow () {
// Setup widgets
set_size_request(300, 300);
set_type_hint(WindowTypeHint.DESKTOP);
textLabel = new Clutter.Text();
Clutter.Threads.Idle.add(() => {
textLabel.set_text("foo");
return true;
});
// Add widgets
get_stage().add_child(textLabel);
show_all();
}
}
public static void main (string [] args) {
GtkClutter.init (ref args);
var win1 = new BackgroundWindow();
var win2 = new BackgroundWindow();
Gtk.main();
}
(run with vala --pkg clutter-1.0 --pkg clutter-gtk-1.0 --pkg gtk+-3.0 test.vala
)
This error looks very erratic and random, and it's hard to pinpoint what is happening exactly. Here are some experiments I did:
- Comment one of the window declarations (e.g.
var win2 = new BackgroundWindow();
) and it runs fine - Comment
set_type_hint(WindowTypeHint.DESKTOP);
and it runs fine - Comment
textLabel.set_text("foo");
and it runs fine
Could this be some sort of data race problem? I tried adding a mutex section inside the callback (even though Clutter.Threads
is already protected with a lock), but it changed nothing.
Edited by Ricardo Subtil