From: Matthias Neeracher Date: Sat, 21 Jun 1997 04:38:35 +0000 (+1200) Subject: sv_vcatpvfn hogs memory [Patch included] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7bc39d6220d2b77d9c5827625d97cd2af6ef9c56;p=p5sagit%2Fp5-mst-13.2.git sv_vcatpvfn hogs memory [Patch included] This is a bug report for perl from neeri@iis.ee.ethz.ch For each %x element to be inserted, sv_vcatpvfn grows the sv to SvLEN + the size of the element. I strongly suspect that this is a typo, as this totally defeats the purpose of the sv_grow buffering and leads to huge sv's with most memory unallocated. I have included a patch that I believe to be correct; I am not 100% sure whether the "+1" is needed, too, but I suspect that it is. As an aside, from my past two bug reports, I'm starting to believe that it might be worthwhile to add monitoring of memory consumption to the execution of the perl test suite: I noticed the bug when the execution of the seemingly innocuous comp/colon.t failed with an out of memory error attempting to allocate a huge (>10M) sv. I assume that the execution of comp/colon.t on an UNIX system would consume just as much memory, but is not usually noticed because a VM system can easily absorb this. Adding memory consumption figures to the test reports, if this is possible to do in a portable way, might uncover more bugs like this. p5p-msgid: 199706211521.RAA12778@solar.ethz.ch --- diff --git a/sv.c b/sv.c index ce85a4b..1d50cf8 100644 --- a/sv.c +++ b/sv.c @@ -4630,7 +4630,7 @@ sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, used_locale) need = (have > width ? have : width); gap = need - have; - SvGROW(sv, SvLEN(sv) + need); + SvGROW(sv, SvCUR(sv) + need + 1); p = SvEND(sv); if (esignlen && fill == '0') { for (i = 0; i < esignlen; i++)