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 749696 - Segfault with Gom
Segfault with Gom
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2015-05-21 19:59 UTC by Mathieu Bridon
Modified: 2015-07-06 07:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A simple example using Gom in C (4.19 KB, text/plain)
2015-05-21 20:02 UTC, Mathieu Bridon
  Details
My attempt at using Gom in Python (956 bytes, text/plain)
2015-05-21 20:07 UTC, Mathieu Bridon
  Details
Handle gtype marshalling (1.22 KB, patch)
2015-07-05 09:34 UTC, Mathieu Bridon
committed Details | Review
My attempt at using Gom in Python (1.24 KB, text/plain)
2015-07-05 09:52 UTC, Mathieu Bridon
  Details
tests: add a test for test_glist_gtype_container_in() (1.15 KB, patch)
2015-07-05 10:00 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Mathieu Bridon 2015-05-21 19:59:23 UTC
I'm trying to use Gom from a Python script.

The process dies with the following output:

  ** (process:5554): CRITICAL **: Unsupported type GType
  **
  Gom:ERROR:gom/gom-command-builder.c:418:gom_command_builder_build_create: assertion failed: (primary_pspec)
  Abandon (core dumped)

See attachments for more details.
Comment 1 Mathieu Bridon 2015-05-21 20:02:13 UTC
Created attachment 303782 [details]
A simple example using Gom in C

This is a simple example showing how to use Gom in C.

Compile it as follows:

  $ gcc -o test-gom -g \
            $(pkg-config --cflags gom-1.0) \
            $(pkg-config --libs gom-1.0) \
            test-gom.c

When running it, it prints:

  $ ./test-gom 
  Item: id=1, name='item1'

This is the reference, what I'd like to try and reproduce with Python.
Comment 2 Mathieu Bridon 2015-05-21 20:07:02 UTC
Created attachment 303783 [details]
My attempt at using Gom in Python

I'm trying to reproduce the previously-attached C example in Python.

When running it, it fails:

  $ python test-gom.py
  ** (process:5554): CRITICAL **: Unsupported type GType
  **
  Gom:ERROR:gom/gom-command-builder.c:418:gom_command_builder_build_create: assertion failed: (primary_pspec)
  Abandon (core dumped)

The error in Gom is triggered by line 24 of the Python script:

  repository.automatic_migrate_sync(1, [ItemResource.__gtype__])

Compare with how this looks in C:

  GList *object_types;
  object_types = g_list_prepend (NULL, GINT_TO_POINTER (ITEM_TYPE_RESOURCE));
  ret = gom_repository_automatic_migrate_sync (repository, 1, object_types, &error);

So in C I'm passing a GList with a single GType item, and in Python a list with a single GType item, which I'd expect to work.
Comment 3 Mathieu Bridon 2015-05-21 20:08:07 UTC
After some discussion on IRC:

<lazka> bochecha_, had a quick look. it's a pygobject bug
<lazka> 1. gtype in glist support is missing 2. error handling code is missing resulting in garbage passed to gom
Comment 4 Mathieu Bridon 2015-07-05 09:34:36 UTC
Created attachment 306846 [details] [review]
Handle gtype marshalling
Comment 5 Mathieu Bridon 2015-07-05 09:52:25 UTC
Created attachment 306847 [details]
My attempt at using Gom in Python

A Python script that actually works.

After applying the patch I submitted earlier, the script I had originally submitted still had a few issues.

This new version actually works, provided:

1. the patch for this bug is applied
2. this patch is applied to gom: https://bugzilla.gnome.org/show_bug.cgi?id=751977
Comment 6 Christoph Reiter (lazka) 2015-07-05 10:00:31 UTC
Created attachment 306849 [details] [review]
tests: add a test for test_glist_gtype_container_in()

This (optionally) depends on https://bugzilla.gnome.org/show_bug.cgi?id=751978 in gobject-introspection
Comment 7 Simon Feltman 2015-07-06 03:38:35 UTC
Review of attachment 306846 [details] [review]:

Looks good, thanks.
Comment 8 Simon Feltman 2015-07-06 03:39:09 UTC
Review of attachment 306849 [details] [review]:

Thanks for adding tests.
Comment 9 Mathieu Bridon 2015-07-06 07:43:05 UTC
Attachment 306846 [details] pushed as f69ce9f - Handle gtype marshalling