Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!apollo!vinoski From: vinoski@apollo.HP.COM (Stephen Vinoski) Newsgroups: comp.lang.perl Subject: Re: Memory leak in PERL PL-41 ? Keywords: bug PERL meory-leak Message-ID: <4e70bf99.20b6d@apollo.HP.COM> Date: 6 Dec 90 21:04:00 GMT References: <5052@taux01.nsc.com> Sender: root@apollo.HP.COM Reply-To: vinoski@apollo.HP.COM (Stephen Vinoski) Organization: Hewlett-Packard Company, Apollo Division; Chelmsford, MA Lines: 48 In article <5052@taux01.nsc.com> arielf@taux01.nsc.com (Ariel Faigon) writes: >The following program should actually print-out its input. >Instead it outputs (note the 'cde:' garbage on the second line): >: 0; abcde >: cde:345678923456789ABCDEFGHIJKLMNOPQRSTUVWXYZfghijklmnopqrstuvwxyz >end of example > >Looks like some kind of memory-leak to me. > >#!/usr/local/bin/perl >while () { > print $_; > while (/(: \d+; )/) {s/$1//;} > s/abcde//; >} >__END__ >: 0; abcde >: 1; 2345678923456789ABCDEFGHIJKLMNOPQRSTUVWXYZfghijklmnopqrstuvwxyz >end of example My fixed version of perl pl41 does the right thing with this. The same bug probably caused the corruption Randal reported a few articles back, too. Larry has been notified of the bug causing this; meanwhile, here is an unofficial patch for the problem: *** str.c.old Fri Nov 16 20:23:48 1990 --- str.c Sat Nov 17 12:32:11 1990 *************** *** 804,809 **** --- 804,810 ---- if (get_paragraph && oldbp) obpx = oldbp - str->str_ptr; bpx = bp - str->str_ptr; /* prepare for possible relocation */ + str->str_cur = bpx; STR_GROW(str, str->str_len + append + cnt + 2); bp = str->str_ptr + bpx; /* reconstitute our pointer */ if (get_paragraph && oldbp) -steve -- | Steve Vinoski (508)256-6600 x5904 | Internet: vinoski@apollo.hp.com | | Testability and Diagnostics | UUCP: ...mit-eddie!apollo!vinoski| | HP Apollo Division, Chelmsford, MA 01824 | ...uw-beaver!apollo!vinoski|