[OpenSIPS-Devel] [ opensips-Patches-3599210 ] fix memory leak in perl.so

SourceForge.net noreply at sourceforge.net
Wed Jan 2 14:29:48 CET 2013


Patches item #3599210, was opened at 2013-01-02 05:24
Message generated for change (Comment added) made by ratner2
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086412&aid=3599210&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: modules
>Group: trunk
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: bratner (ratner2)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix memory leak in perl.so

Initial Comment:
fixes perl_exec2() in perlfunc.c. The message object that is passed to the perl-script 
was left hanging after every call to perl_exec() in the opensips script. 

Moved the declaration of OpenSIPS::Message object to the SAVETMPS/FREETMPS 
segment so it will be freed before the function returns. 

Tested by using Devel::Gladiator. 



----------------------------------------------------------------------

>Comment By: bratner (ratner2)
Date: 2013-01-02 05:29

Message:
--- modules/perl/perlfunc.c	(revision 9540)
+++ modules/perl/perlfunc.c	(working copy)
@@ -127,14 +127,16 @@
 		return -1;
 	}
 
-	m = sv_newmortal();
-	sv_setref_pv(m, "OpenSIPS::Message", (void *)_msg);
-	SvREADONLY_on(SvRV(m));
 
 
 	ENTER;				/* everything created after here */
 	SAVETMPS;			/* ...is a temporary variable.   */
 	PUSHMARK(SP);			/* remember the stack pointer    */
+
+	m = sv_newmortal();		/* create a mortal SV to be killed on FREETMPS */
+	sv_setref_pv(m, "OpenSIPS::Message", (void *)_msg); /* bless the message
with a class */
+	SvREADONLY_on(SvRV(m));		/* set the content of m to be readonly  */
+
 	XPUSHs(m);			/* Our reference to the stack... */
 
 	if (mystr)
@@ -151,6 +153,5 @@
 	PUTBACK;
 	FREETMPS;			/* free that return value        */
 	LEAVE;				/* ...and the XPUSHed "mortal" args.*/
-
 	return retval;
 }


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086412&aid=3599210&group_id=232389



More information about the Devel mailing list