Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seg fault on multiple calls to find_components() #63

Closed
larryprice opened this issue Aug 11, 2016 · 4 comments
Closed

Seg fault on multiple calls to find_components() #63

larryprice opened this issue Aug 11, 2016 · 4 comments
Assignees
Labels

Comments

@larryprice
Copy link
Contributor

After upgrading to newer versions of appstream (0.9.7-1 and now 0.9.8-1 on ubuntu 16.10), I am getting consistent crashes when calling find_components consecutively from python3. This script dumps for me every time:

#!/usr/bin/env python

import gi
gi.require_version('AppStream', '1.0')
from gi.repository import AppStream

db = AppStream.Database()
db.open()

db.find_components("gedit", None) # Fine, continue...
db.find_components("gedit", None) # Crash!

The results:

./break_appstream.py:11: Warning: invalid unclassed pointer in cast to 'AsComponent'
  db.find_components("gedit", None) # Crash!
**
GLib:ERROR:/build/glib2.0-4NbKb8/glib2.0-2.49.2/./glib/ghash.c:373:g_hash_table_lookup_node: assertion failed: (hash_table->ref_count > 0)
Aborted (core dumped)

Am I using this incorrectly? I've tried running appstreamcli refresh --force --verbose and seen nothing interesting. I've reproduced this exact issue on another machine. I tested on a machine with ubuntu 16.04 and found that version 0.9.4-1ubuntu1 still works as expected.

@ximion ximion added the bug label Aug 11, 2016
@ximion ximion self-assigned this Aug 11, 2016
@ximion
Copy link
Owner

ximion commented Aug 11, 2016

This is a really weird issue... Apparently, the token_cache hash table is dead. This can only happen though, if the AsComponent which owns it is also dead.
And that should never happen, unless Python manually kills the objects inside the result array, which it shouldn't do (the result array is marked as transfer full, which means that the array itself should be freed, not its contents).

@ximion
Copy link
Owner

ximion commented Aug 11, 2016

Oh crap! Apparently Python3 treats a GPtrArray as a full-blown container type, meaning that it will free its contents... So, the annotation there is wrong, it should only mark the container as transferred.

@ximion ximion closed this as completed in 6920910 Aug 11, 2016
@ximion
Copy link
Owner

ximion commented Aug 11, 2016

The following code works now with Git master:

#!/usr/bin/env python3

import gi
gi.require_version('AppStream', '1.0')
from gi.repository import AppStream

pool = AppStream.Pool()
pool.load()

pool.search("gedit")
res = pool.search("gedit") # No more crashes!

for cpt in res:
    print(cpt.get_id())

I will probably backport this patch to the AppStream version in Debian Unstable / Ubuntu Yakkety, but both should ship with AppStream 0.10 or higher anyway :)

Thank you for reporting this issue!
(and I wonder whether it would be possible to have a testsuite for Python stuff as well)

@ximion
Copy link
Owner

ximion commented Aug 31, 2016

Fixed package is uploaded to Debian and will hopefully also land in Ubuntu soonish :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants