Re: [PATCH] Fix refcounting bug in typecaster
Federico Di Gregorio <fog-NGVKUo/i/[email protected]> Thu, 08 Apr 2010 18:24:01 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On 07/04/2010 21:19, Michael Tharp wrote: > I have found the cause of the assertion error from earlier. The key was > getting it through my insufficiently-caffeinated skull that the crash > was happening in the middle of a call to the caster function, where a > new object being instantiated triggered a garbage collection. The GC > then trips over a too-small refcount on the type object which is > reachable twice even though the refcnt is only 1. I created a test case out of your example code but my psycopg2 on Python 2.5 passes the test here. Can you please run the test and confirm that it shows the problem? Test code attached to this email. federico -- Federico Di Gregorio fog-NGVKUo/i/[email protected] Beh un bacio, se ben dato, non si rifiuta. -- <laura> _______________________________________________ Psycopg mailing list Psycopg-IAPFreCvJWPBWskQ1e/[email protected] http://lists.initd.org/mailman/listinfo/psycopg
bug_gc.py
(text/x-python, 784 B)
#!/usr/bin/env python
import psycopg2
import psycopg2.extensions
import time
import unittest
import gc
import sys
if sys.version_info < (3,):
import tests
else:
import py3tests as tests
class StolenReferenceTestCase(unittest.TestCase):
def test_stolen_reference_bug(self):
def fish(val, cur):
gc.collect()
return 42
conn = psycopg2.connect(tests.dsn)
UUID = psycopg2.extensions.new_type((2950,), "UUID", fish)
psycopg2.extensions.register_type(UUID, conn)
curs = conn.cursor()
curs.execute("select 'b5219e01-19ab-4994-b71e-149225dc51e4'::uuid")
curs.fetchone()
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main()
signature.asc
(application/pgp-signature, 262 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAku+AzQACgkQvcCgrgZGjeupegCguT7ZcLCb5BZss+WZppH3IlJr tSEAn1CFLH8HBv6wsl0tYR7yRkJmYSNL =m3+4 -----END PGP SIGNATURE-----