Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 21380
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: smarshall [...] wsi.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 2.0.0



CC: Stephen Marshall <smarshall [...] wsi.com>
Subject: Memory leak in DBD-Pg (lack of mortalization)
Date: Thu, 07 Sep 2006 14:28:17 -0400
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Marshall <smarshall [...] wsi.com>
I've found a memory leak in DBD-Pg when the pg_notifies function is called. The return value needs to be mortalized; the failure to do so causes about 100 bytes of memory to be lost each time pg_notifies is called. I have posted the one-line patch for this to the dbdpg project on gborg. The same patch is also attached below. I have a pair of perl scripts that demonstrates this problem and show that the fix works. One scripts listens while the other does very rapidfire notifications. I am happy to make these scripts available on request. On a related note, while looking through the code trying to understand when variables should be "mortalized", it appeared to me that there are three other memory leaks in dbdimp.c, in the function dbd_st_FETCH_attrib. These are very minor, but I'm wondering if some "mortalization" expert could check these to see if these return values (retsv below) should be wrapped in a sv_2mortal call? Thanks, Steve Marshall ---- Code with possible memory leaks at return retsv ---- SV * dbd_st_FETCH_attrib (sth, imp_sth, keysv) SV *sth; imp_sth_t *imp_sth; SV *keysv; { STRLEN kl; char *key = SvPV(keysv,kl); int i, x, y, sz; SV *retsv = Nullsv; sql_type_info_t *type_info; if (dbis->debug >= 4) { (void)PerlIO_printf(DBILOGFP, "dbdpg: dbd_st_FETCH (%s) sth=%d\n", key, sth); } /* Some can be done before the execute */ if (15==kl && strEQ(key, "pg_prepare_name")) { retsv = newSVpv((char *)imp_sth->prepare_name, 0); return retsv; } else if (17==kl && strEQ(key, "pg_server_prepare")) { retsv = newSViv((IV)imp_sth->server_prepare); return retsv; } else if (14==kl && strEQ(key, "pg_prepare_now")) { retsv = newSViv((IV)imp_sth->prepare_now); return retsv; } ---- Patch for confirmed memory leak in pg_notifies: ---- *** dbdimp.c.1.49 2006-08-29 16:04:37.000000000 -0400 --- dbdimp.c 2006-08-29 16:23:32.000000000 -0400 *************** *** 832,838 **** retsv = newRV(sv_2mortal((SV*)ret)); ! return retsv; } /* end of dbd_db_pg_notifies */ --- 832,838 ---- retsv = newRV(sv_2mortal((SV*)ret)); ! return sv_2mortal(retsv); } /* end of dbd_db_pg_notifies */
Subject: Re: [rt.cpan.org #21380] Fix checked into dbdimp.c, revision 1.185
Date: Mon, 18 Sep 2006 11:00:03 -0400
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Marshall <smarshall [...] wsi.com>
I have checked in a fix to this bug. I expect the change to be part of DBD-Pg 1.50.
Subject: Re: [rt.cpan.org #21380] Fix checked into dbdimp.c, revision 1.185
Date: Mon, 18 Sep 2006 11:00:03 -0400
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Marshall <smarshall [...] wsi.com>
I have checked in a fix to this bug. I expect the change to be part of DBD-Pg 1.50.
Subject: Re: [rt.cpan.org #21380] Fix for memory leak in pg_notifies
Date: Mon, 18 Sep 2006 12:47:56 -0400
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Marshall <smarshall [...] wsi.com>
I also submitted a patch for this bug. I've actually submitted this patch three times previously, each to different places. I integrated it in the dbdpg CVS repository on gborg, posted it to DBD-Pg patches on gborg, and attached the patch to the bug report. I'll include it again for completeness, but I could really benefit from knowing how to provide patch information so it can be used more efficiently. Thanks, Steve Marshall David Wheeler via RT wrote: Show quoted text
><URL: http://rt.cpan.org/Ticket/Display.html?id=21392 > > >On Sep 18, 2006, at 08:06, Stephen Marshall via RT wrote: > > >
>> Queue: DBD-Pg >> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=21392 > >> >>I have checked in the fix to this bug, so it should be marked as >>resolved. >> >>I expect the fix will be release in DBD-Pg version 1.50. >> >>
> >The GBorg CVS is deprecated. Please send a patch for us to check it >in to the new repository, svn.perl.org. > >Thanks, > >David > > > > > >
*** dbdimp.c.1.49 2006-08-29 16:04:37.000000000 -0400 --- dbdimp.c 2006-08-29 16:23:32.000000000 -0400 *************** *** 832,838 **** retsv = newRV(sv_2mortal((SV*)ret)); ! return retsv; } /* end of dbd_db_pg_notifies */ --- 832,838 ---- retsv = newRV(sv_2mortal((SV*)ret)); ! return sv_2mortal(retsv); } /* end of dbd_db_pg_notifies */
Subject: Re: [rt.cpan.org #21380] Fix for memory leak in pg_notifies
Date: Mon, 18 Sep 2006 10:06:02 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
On Sep 18, 2006, at 09:55, Stephen Marshall via RT wrote: Show quoted text
> I also submitted a patch for this bug. I've actually submitted this > patch three times previously, each to different places. I > integrated it > in the dbdpg CVS repository on gborg, posted it to DBD-Pg patches on > gborg, and attached the patch to the bug report. I'll include it > again > for completeness, but I could really benefit from knowing how to > provide > patch information so it can be used more efficiently.
This is the place. Hopefully Greg can clear out his queue of tasks a bit to review the slew of patches and reports here soon.
Subject: Re: [rt.cpan.org #21380] Fix for memory leak in pg_notifies
Date: Mon, 18 Sep 2006 14:13:09 -0400
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Marshall <smarshall [...] wsi.com>
David Wheeler via RT wrote: Show quoted text
>>I could really benefit from knowing how to provide >>patch information so it can be used more efficiently. >> >>
> >This is the place. Hopefully Greg can clear out his queue of tasks a >bit to review the slew of patches and reports here soon. > >
I have a login account on rt.cpan.org now, but I'm still not sure what to do with it. I can browse the bug lists for the project of my choice, but I could do that before, even without an account. I do not understand how I can affect the status of the bugs I submit (e.g. set their Status, Severity, Broken in, and Fixed in attributes). Is this done by sending emails with the bug number in the subject line? If so, are there special tags you must put in the email to affect these attributes? I also do not understand how to submit code patches. Am I just supposed to send an email with the patch as an attachment, or is their someway I can "flag" the email so that it is obvious to maintainers that their is a code fix here, not just an observation of a problem? Thanks for any insight you can share, Steve
Subject: Re: [rt.cpan.org #21380] Fix for memory leak in pg_notifies
Date: Mon, 18 Sep 2006 11:20:44 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
On Sep 18, 2006, at 11:13, Stephen Marshall via RT wrote: Show quoted text
> I have a login account on rt.cpan.org now, but I'm still not sure what > to do with it. I can browse the bug lists for the project of my > choice, > but I could do that before, even without an account.
Yes, the account should not matter, although if you're logged in with the email address you used to create a bug, I think that you can do more than if you were anonymous. Show quoted text
> I do not understand how I can affect the status of the bugs I submit > (e.g. set their Status, Severity, Broken in, and Fixed in attributes). > Is this done by sending emails with the bug number in the subject > line? > If so, are there special tags you must put in the email to affect > these > attributes?
I'm browsing the DBD-mysql queue, since I should have the same permission there as you have for DBD-Pg. I click the subject for a bug report, and it brings up a screen. To change the status of a bug, I click the "The Basics" header. There I was able to change the status and submit it. Permission was denied, but as I said, I did not file the bug report, so maybe you could change it for bugs you've submitted. Show quoted text
> I also do not understand how to submit code patches. Am I just > supposed > to send an email with the patch as an attachment, or is their > someway I > can "flag" the email so that it is obvious to maintainers that > their is > a code fix here, not just an observation of a problem?
Yes, just send it attached to an email, that's the easiest way. Show quoted text
> Thanks for any insight you can share,
HTH, and thanks for making the effort, we appreciate it! Best, David
Patched in subversion: thanks for the report. Thanks also for the heads up on other mortalization problems: we'll check into those, but feel free to raise specific bugs on them as well as you find them.