Re: psycopg2 2.0.8 - segmentation fault

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno mer, 15/04/2009 alle 22.35 +0530, Gangadharan S.A. ha scritto:
>         Program received signal SIGABRT, Aborted.
>         [Switching to Thread 1283557696 (LWP 12437)]
>         0x00002b2fdc478535 in raise () from /lib64/libc.so.6
>         (gdb) bt
>         #0  0x00002b2fdc478535 in raise () from /lib64/libc.so.6
>         #1  0x00002b2fdc479990 in abort () from /lib64/libc.so.6
>         #2  0x00002b2fdc4af6db in __libc_message ()
>         from /lib64/libc.so.6
>         #3  0x00002b2fdc4b48fe in malloc_printerr ()
>         from /lib64/libc.so.6
>         #4  0x00002b2fdc4b5f36 in free () from /lib64/libc.so.6
>         #5  0x00002b2fe062f7e7 in connection_dealloc
>         (obj=0x2aaaaac0ef30) at psycopg/connection_type.c:464
> 
> I managed to reproduce and fix the issue. This is happening because
> when dealloc-ing, the "Py_BEGIN_ALLOW_THREADS;" in conn_close is
> letting other threads launch the garbage collector which in turn ends
> up running the dealloc a second time.
> 
> The fix is to untrack the connnection object from GC, before going
> ahead with dealloc, as said in
> http://docs.python.org/c-api/gcsupport.html
> 
> "Similarly, the deallocator for the object must conform to a similar
> pair of rules: 
>      1. Before fields which refer to other containers are invalidated,
>         PyObject_GC_UnTrack must be called.

One always learn something. Thank you _very_ much for this patch.

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
  Se consideri l'uso del software libero una concessione tu stesso,
   come potrai proporla agli altri?                         -- Nick Name

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAknmVG0ACgkQvcCgrgZGjeufmwCgllp3zDcfjxCX4YtnBudx48v8
1SEAn1OXJZnJlPLOvBCTdVwkoORkNSCa
=MUKW
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.