After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729643 - Segfault when using ClutterGst in non GNOME Shell Window Managers
Segfault when using ClutterGst in non GNOME Shell Window Managers
Status: RESOLVED OBSOLETE
Product: clutter-gst
Classification: Other
Component: general
2.0.x
Other Linux
: Normal blocker
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 727851
 
 
Reported: 2014-05-06 12:41 UTC by Lubosz Sarnecki
Modified: 2021-05-25 17:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example of the crash with everything imported and in the right order (1.14 KB, text/x-python)
2014-05-28 15:03 UTC, Lubosz Sarnecki
Details
stacktrace (18.00 KB, text/plain)
2014-05-28 15:16 UTC, Christoph Reiter (lazka)
Details

Description Lubosz Sarnecki 2014-05-06 12:41:58 UTC
The following minimal example crashes:
https://bug727851.bugzilla-attachments.gnome.org/attachment.cgi?id=273832

The crash does not occur if:
* You run the example as root
* You run the example in GNOME Shell and import Gdk (which is not called directly)


The full example, where you can see what we are trying to achieve:
https://bug727851.bugzilla-attachments.gnome.org/attachment.cgi?id=273831


For more information you can read the Pitivi bug report:
https://bugzilla.gnome.org/show_bug.cgi?id=727851


Related bug reports in distribution trackers:
https://bugs.archlinux.org/task/39714
https://bugs.launchpad.net/ubuntu/+source/pitivi/+bug/1307746
Comment 1 Lionel Landwerlin 2014-05-28 14:20:03 UTC
Your first example is missing the Gtk initialization call.
Comment 2 Christoph Reiter (lazka) 2014-05-28 14:33:18 UTC
If you are referring to Gtk.init, that gets called by the Python overrides on import.
Comment 3 Lubosz Sarnecki 2014-05-28 15:03:05 UTC
Created attachment 277394 [details]
Example of the crash with everything imported and in the right order

Why did you close this bug? It crashes even with everything included. The point of the first "minimal" example was just to show how the crash is reproducible in a minimal fashion.

Here you have a full example that imports everything and initializes everything (in the right order, reordering did not fix it).

Please note that the crash only occurs in GNOME Classic and other window managers, that are not GNOME Shell.

What is very interesting is that I cannot reproduce this bug when I build the Gtk / Gst stack with cerbero (the GStreamer build system), even when I use the same versions as in Arch Linux.

This could be an Arch Linux / Ubuntu packaging bug, but I would expect more support, or even ideas, from the library developer side.
Comment 4 Christoph Reiter (lazka) 2014-05-28 15:16:47 UTC
Created attachment 277395 [details]
stacktrace
Comment 5 Mathieu Duponchelle 2014-05-28 15:55:37 UTC
I don't understand how a segfault is "NOTABUG" to be honest. A little explanation from whoever closed that report would be welcome :)
Comment 6 Christoph Reiter (lazka) 2014-05-28 16:04:26 UTC
Mathieu: In Lionel's defense, it's not obvious that gtk_init() gets called by pygobject while not for any other module. And leaving out initialization often times results in a segfault.
Comment 7 Mathieu Duponchelle 2014-05-28 22:57:16 UTC
Hi Christophe, no need to defend anyone, I was not in an attacking mood, just asking for more explanation, as I think closing that bug as NOTABUG is incorrect and would like to understand the reasoning behind that.

If as you say, it has been closed because of the absence of the initialization of Gtk, it is indeed not a good reason as, as you pointed out, Gtk is initialized on import by the overrides.

From my investigation at the moment I devised the (admittedly hacky) solution of importing Gdk first, I remember this indeed had to do with ordering of various project's initializations, but the issue only started to show up in pitivi when we started using ClutterGst, which leads me to think part of the problem may be triggered / created by ClutterGst or its potential overrides.

I'm afraid I don't remember much more about the exact issue, but I sure know there is something fishy happening with these various modules' interaction.

If I remember correctly, the whole initialization scheme problem was tackled by someone at that moment (~6 months ago), possibly Simon Feltman.
Comment 8 Simon Feltman 2014-05-29 08:17:55 UTC
(In reply to comment #7)
> If I remember correctly, the whole initialization scheme problem was tackled by
> someone at that moment (~6 months ago), possibly Simon Feltman.

Naw, just a passerbyer :)

This gives some of the history: https://bugzilla.gnome.org/show_bug.cgi?id=727851#c7

It might be worth porting the crashing example with correct initialization ordering to Gjs or C to get more traction on solving this...
Comment 9 Lubosz Sarnecki 2014-05-30 12:22:11 UTC
I was able to reproduce the crash in C. 
https://gist.github.com/lubosz/7af14e62087b6af5f85f

It shows the same behavior as in Python:

* Does not occur in GNOME Shell
* Does not occur when using sudo

In JavaScript though, it does occur always.
https://gist.github.com/lubosz/e01eba5b7ce5240a6219

Funny thing about GJS: Gdk.init also crashes.

This crashes:
#!/usr/bin/env gjs
const Gdk = imports.gi.Gdk;
Gdk.init(ARGV);


Maybe this issue should be reassigned to Gdk?

It's also not a bindings issue, since it crashes in C.
Comment 10 Lubosz Sarnecki 2014-05-30 12:46:58 UTC
Why I think that the problem is within ClutterGst, is that this minimal JavaScript example crashes when you initialize ClutterGst

https://gist.github.com/lubosz/db4337a39d537f2f6c79

I used JavaScript, since it also crashes in GNOME Shell there. I expect this to crash in C on GNOME Classic.
Comment 11 Lionel Landwerlin 2014-05-30 13:37:06 UTC
Here is an example of how to initialize stuff :

https://pastebin.mozilla.org/5291862

I can't remember the details, but the best you can do is getting warnings (instead of crash).
Comment 12 Lubosz Sarnecki 2014-05-30 14:32:40 UTC
Yes this also does cause warnings for me, but works in JavaScript. 

ClutterGst.init(null);
GtkClutter.init(null);

It also works in C with non GNOME Shell.

clutter_gst_init (&argc, &argv);
gtk_clutter_init(&argc, &argv);

The funny thing is that this does not work when Gtk.init is called.
In Python Gtk.init seems to be called on import.

from gi.repository import Gtk
ClutterGst.init([])
GtkClutter.init([])

So this only works in C and JavaScript.

In GNOME Shell, importing Gdk first fixes the problem.

from gi.repository import Gdk

Switching the initialization of ClutterGst and GtkClutter fixes also the warnings on GNOME Shell. This is how it is done in Pitivi.
But this crashes in non GNOME Shell.
Comment 13 Lubosz Sarnecki 2014-05-30 14:41:53 UTC
I was able to run the example with warnings in Python (non GNOME Shell), with this import order:

from gi.repository import ClutterGst
ClutterGst.init([])
from gi.repository import GtkClutter
GtkClutter.init([])

from gi.repository import Gdk
from gi.repository import Clutter
from gi.repository import Gst
from gi.repository import Gtk

This also works in Pitivi, but distaches the clutter timeline. For the clutter timeline to be drawn correctly, Pitivi needs to import GtkClutter before ClutterGst.
Comment 14 Simon Feltman 2014-06-02 01:06:32 UTC
I've also logged bug 731091 in an effort to have better control over Python import and initialization orderings (among other problems).
Comment 15 André Klapper 2021-05-25 17:32:48 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new enhancement request ticket at
  https://gitlab.gnome.org/GNOME/clutter-gst/-/issues/

Thank you for your understanding and your help.