-
Notifications
You must be signed in to change notification settings - Fork 16
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
Cairo Segfaults #20
Comments
Thanks. Yeah, lots of things missing there.. that's also why the GC gets disabled in the example to make it at least kinda work. |
Well I see a figure window pop up with gdb it stays, without the segfault crashes python and so it closes almost immediately. With gdb I don't see a plot, just an empty window... Would using python2.7 instead of pypy affect this? By the way let me introduce myself, I collaborate over on the matplotlib project, and one of my recent PRs incorporates Even if |
hmm, just twigged whether with "lots of things missing there" you referred to pgi (as I had assumed) or to the gdb trace I sent. Hopefully this week I will figure out how to get a fuller stack trace for you... slowly learning how to use gdb. If I can help I will. |
right, now hot on the tail of this bug, no idea whether this comes from |
@lazka FOUND IT! Okay, I have found that commenting out these lines in if HAS_CAIRO_CFFI:
ctx = cairo.Context._from_pointer(
cairo.ffi.cast('cairo_t **', id(ctx) + object.__basicsize__)[0],
incref=True) That call passes, with the segfault occurs after this line has executed, so not exactly sure why commenting this out allows it to work... maybe it circumvented some logic in pgi... I noticed that before calls from pgi would return a Next step, as a cairo[cffi] noob, I shall find out why we put those lines in, and if you have any ideas why those lines break the pgi implementation... this should help us decide on whether we need to fix |
Update: So, as I see the problem, pgi auto converts Does that sound plausible as an explanation? Can I test that? Can we change that auto-conversion, or does that undermine the basis of pgi by introducing non-cffi objects. If so then I will change the matplotlib codebase, either with a simple |
yes, pygobject uses pycairo while pgi uses cairocffi. The code in matplotlib assumes it gets a pycairo object. We could try to use pycairo when running under CPython, other than that, no idea. The code in matplotlib could check if the given object already is a cairocffi one before trying to convert it, but given the limited use of pgi I don't think that it's worth it. I've successfully used older matplotlib versions, so maybe try with something released ~2014/15 |
Support for cairocffi (and thus those lines) were added to master the 17th January 2014 and released with version 1.4.0 (rc1 on the 13th July and several RCs later, officially released on 26th August), I see the last change to My feelings on which way to use:
I don't think the limited use of pgi now makes much of a difference, instead I find the future use more pertinent. Do you see pgi becoming stable and more usable and which way do you want to take it? In terms of compatibility, I would expect at least a list of places where a concious decision has been made to deviate from the goal of 100% compatibility, i.e. that gtk widgets now return |
Casting a private Python object field to some pointer can hardly be called valid use of an API. pycairo is a CPython extension and can't be used with PyPy, so there is not much choice there..
pgi is currently pretty low on my priority list and I only use it for doc generation atm. I've focused on pygobject instead and also ported some speed improvements from pgi to pygobject in the meantime. |
@lazka Would you take PRs? |
Fair point
Right now I have no reason not to use gobject, but I like pgi as it feels less messy, and hence I find it perfect to use for running matplotlib tests that run gtk. In the future, once it becomes more stable, I don't see any reason why it couldn't replace Current testing shows it works fine with mpl with that modification. Commenting out the lines that disable the gc works fine as on all combinations of the cairo vs agg backends and py3 vs py2 apart from cairo backend with py2, in which case I get a Segmentation Fault. I will now add this fix to my pgi mpl PR. |
Running the matplotlib example, cairo segfaults on my machine (debian-jessie)
If you want more of the backtrace, let me know (I have 133 lines of it).
Other people who have tried to use it (or similar code) have got:
or
The text was updated successfully, but these errors were encountered: