Hi Jason,
On 2012-09-13, Jason Grout <
jason...@creativetrax.com> wrote:
> I've rewritten the code for moving to the new IPython to make it more
> flexible, and I'm running into a puzzling problem. When I call
> quit_sage from an exit handler, for some reason the pari_close() call
> happening inside the pari._unsafe_deallocate_pari_stack function causes
> a segfault.
I've met the same problem, and I my suggestion for a solution is at
#12215 (second patch): Simply rename _unsafe_deallocate_pari_stack into
__dealloc__, and remove the explicit call to
_unsafe_deallocate_pari_stack in sage.all.quit_sage.
I think that's the cleanest solution: As usual with Cython, if you
have C data that need to be freed when the object is deleted, then do so
in __dealloc__. When a (or actually *the unique*) pari
instance becomes garbage collected (or when quitting Sage), then
__dealloc__ is called anyway - there is absolutely no need to manually
deallocate.
The problem with #12215 is that it depends on #715 and #11521, which are
uncovering a problem in libsingular/omalloc that results in a
segmentation fault on bsd.math -- see #13447.
So, it might be a good idea to fix the pari problem independent of all
the memleak fixes in #715 and #11521, if it turns out that pari
deallocation is troublesome in other contexts as well.
Cheers,
Simon