Re: psycopg2 2.0.8 - segmentation fault
"Gangadharan S.A." <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
>
> > 1. All / most of the classes in psycopg2 code seem to have
> > Py_TPFLAGS_HAVE_GC, so they need to a PyObject_GC_UnTrack as their first
> > step: http://docs.python.org/c-api/gcsupport.html . But since psycopg2
> > classes haven't implemented tp_clear either, the actual double dealloc
> > probably won't happen, unless people inherit these classes. (Heap classes
> > get the subtype_clear, tp_clear implementation.)
>
> If the type only uses Py_CLEAR() or equivalent to free its resources,
> then it isn't necessary to untrack the object (although it probably
> won't hurt).
>
> This macro essentially does the following:
>
> tmp = self->whatever;
> self->whatever = NULL;
> if (tmp != NULL) {
> /* free tmp */
> }
>
> Given that the code is protected by the GIL, there isn't a race in
> unsetting the object.
That is true. But there are times when the code voluntarily releases the GIL
from inside the destructor, such as the conn_close in my above 2 fixes.
Then, the garbage collector can end up running concurrent to the current
dealloc. In those cases, we need to untrack the object first.
Btw, I'm trying to decide whether I should manually patch psycopg for my
organization or if I should wait for a release of psycopg with both my
patches in. Can someone please make an estimate on when there will be a
release with both these patches applied (double_dealloc_fix.diff and
cursor_dealloc_fix.diff) ?
Thanks,
Gangadharan
_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg