bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] [BugReport] GAWK 3.1.8 / gsub() memory leak


From: Koehler, Mario
Subject: [bug-gawk] [BugReport] GAWK 3.1.8 / gsub() memory leak
Date: Thu, 29 Nov 2012 09:29:29 +0100

Hi,

 

i would like to report a memory leak in gensub() and gsub() functions of GAWK 3.1.8. The bug seems to be introduced somewhere between 3.1.5 and 3.1.8. Those two versions are the ones I have access to, and in 3.1.5 the bug does not occur, but in 3.1.8 it does.

 

The memory leak scenario can be reproduced with this small AWK script:

 

{

    outputLineTemplate = "COMP_ID-KKTNR-KUKTO|CAP_NAME|CAP_STR KBHNR|PADDED_PLZ|CAP_ORT|BIRTHDAY|256,COMP_NR|TELEPHONE";

    tokenList = "COMP_NR COMP_ID KKTNR KUKTO CAP_NAME BIRTHDAY CAP_STR KBHNR PADDED_PLZ CAP_ORT TELEPHONE"

    tokenCount = split(tokenList, definedTokens, " ");

   

    while (1 > 0) {

         outline = outputLineTemplate;

         for( token = 1; token <= tokenCount; token++ ) {

           gsub(definedTokens[token],"example value",outline);

         }

         print outline;

    }

}

 

The script defines a „template“ for an output line that contains placeholders. Then it iterates over this output line template and replaces each placeholder (token) in the template with a certain value (“example value” in this case). This is repeated in an infinite loop to simulate the processing of a large batch of input lines. The script was originally part of a much larger “conversion script” and this relevant part was extracted from there and slightly modified for the purpose of this bug report.

 

The most important line is the line with the gsub() call (replacing it with gensub() also produces the bug). This call causes a memory leak to occur, which can be easily observed by starting the script and then watch “top” for a while. You will see that the memory usage of the awk process will rise continually.

 

If you repeat this test with GAWK 3.1.5 you will see that the memory usage of the awk process will remain constant at a very low level (couple of KB)

 

I did my testing on SUSE Linux Enterprise Server 11.2 (x86_64).

 

Best regards

Mario Köhler

________________________________________________________________________________

Mario Köhler

Otto Group

Dipl. Inf. · Abteilung · MR-CM-VK

 

Otto (GmbH & Co KG) · Wandsbeker Straße 3-7 · 22172 Hamburg

Telefon +49 40 6461-5682 · Fax +49 40 6461-5682

mailto:address@hidden

________________________________________________________________________________

Besuchen Sie uns auf:

Karriere machen:

og_logo  www.ottogroup.com

og_logo  www.ottogroup.com/karriere

________________________________________________________________________________

 

AG Hamburg, HR A 62 024, Persönlich haftend: Verwaltungsgesellschaft Otto mbH,   

Hamburg, AG Hamburg, HR B 13 762 vertr. durch: Hans-Otto Schrader (Vorsitzender) •   

Dr. Rainer Hillebrand (Stellvertretender Vorsitzender) • Alexander Birken • Dr. Michael   

Heller • Dr. Timm Homann • Hanjo Schneider • Jürgen Schulte-Laggenbeck • Dr. Winfried Zimmermann   

Aufsichtsrat: Dr. Michael Otto (Vorsitzender)

________________________________________________________________________________


OT121 Signatur-Baum-Gruen SAVE PAPER - THINK BEFORE YOU PRINT

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]