Skip site navigation (1) Skip section navigation (2)

Re: "double free" segfault back in pyscopg2 2.5

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: "double free" segfault back in pyscopg2 2.5
Date: 2013-06-20 15:22:20
Message-ID: (view raw, whole thread or download thread mbox)
Lists: psycopg
On Thu, 2013-06-20 at 19:34 +0530, Gangadharan S.A. wrote:
> Hi,
> It looks like the "double free" segfault from pyscopg2 2.0.8
> ( )
> is back in version 2.5:
> As before, the problem seems to be that when de-allocing the
> connection, we are calling conn_close before untracking the object.
> conn_close allows other threads to run and call the garbage collector,
> which ends up running dealloc a second time on this object. So we free
> the same memory a second time and hence the double free error.
> The fix would be to call conn_close after untracking the object in
> connection_type.c:connection_dealloc().

I see: sorry, I've broken it in commit 5aafe38f. Looks like in that
commit I've fixed the cursor and broken the connection.

> The script used to reproduce the issue back in
> will
> not reproduce the issue any more because we don't rollback the
> in-progress transaction during connection close anymore. The only way
> I reliably could reproduce the issue in a test script was to introduce
> a sleep in the C code at connection_int.c:conn_close() after
> Py_BEGIN_ALLOW_THREADS and then run garbage collector from another
> thread during the sleep.
> Thanks,
> Gangadharan

Thank *you* very much. Open ticket #166. I had in mind to release a new
version in the next days: will include this correction too.


In response to

psycopg by date

Next:From: Daniele VarrazzoDate: 2013-06-20 15:42:21
Subject: Re: "double free" segfault back in pyscopg2 2.5
Previous:From: Gangadharan S.A.Date: 2013-06-20 14:04:29
Subject: "double free" segfault back in pyscopg2 2.5

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group