From: David Mitchell Date: Fri, 8 Jan 2010 23:31:45 +0000 (+0000) Subject: fix for [perl #66108] Leaked scalars X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7fa38291524c327a3cb23bfe94979e1537743cac;p=p5sagit%2Fp5-mst-13.2.git fix for [perl #66108] Leaked scalars @DB::args is a hack: it gets set with non-refcounted aliases of the caller's @_ elements. Once the sub that ran caller() has exited, @DB::args will contain garbage: elements will be SVs that have been freed, re-assigned etc. So as a minimum, when cloning an interpreter, skip cloning @DB::args. --- diff --git a/sv.c b/sv.c index 38a9140..c2757d6 100644 --- a/sv.c +++ b/sv.c @@ -11913,6 +11913,10 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, SvNV_set(&PL_sv_yes, 1); ptr_table_store(PL_ptr_table, &proto_perl->Isv_yes, &PL_sv_yes); + /* dbargs array probably holds garbage; give the child a clean array */ + PL_dbargs = newAV(); + ptr_table_store(PL_ptr_table, proto_perl->Idbargs, PL_dbargs); + /* create (a non-shared!) shared string table */ PL_strtab = newHV(); HvSHAREKEYS_off(PL_strtab); @@ -12039,7 +12043,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_DBsingle = sv_dup(proto_perl->IDBsingle, param); PL_DBtrace = sv_dup(proto_perl->IDBtrace, param); PL_DBsignal = sv_dup(proto_perl->IDBsignal, param); - PL_dbargs = av_dup(proto_perl->Idbargs, param); /* symbol tables */ PL_defstash = hv_dup_inc(proto_perl->Idefstash, param);