Skip to content
Tcl Source Code View Ticket
Login

View Ticket

realloc bug -- somehow related to regsub?

Closed / Fixed218466ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:00:48
OriginalBugID: 627 Bug
Version: 8.1a2
SubmitDate: '1998-05-25'
LastModified: '1999-08-13'
Severity: MED
Status: Released
Submitter: hershey
ChangedBy: hobbs
OS: All
OSVersion: NA
Machine: NA
FixedDate: '1999-08-13'
FixedInVersion: 8.2b3
ClosedDate: '2000-10-25'


I too have encountered this problem.  I have a 2,500 tcl/tk prog
which gets an exception with the new regsub.  If I remove the
call it works (I'm actually running it in production with version 8.0).
I posted a similar warning to the above a couple of months ago
to c.l.t.

Just thought I'd let you know I think the problem is real.  When I
have the time I'll try and get a simple example.  I did try to
at first but failed.

PS I think the new regexp stuff should have been made a "package".
--------
Tcl 8.1a2 is blowing up with the message "unable to realloc xxx bytes"
when I run my program.  My code basically reads HTML files and parses them.
It reads the entire file into a variable, then parses the data from that.
The problem ocurrs for large files, e.g. a file "myfile" that is
971 lines, 15383 characters gives the error.  Small files work fine.

Below is the smallest code fragment that reproduces the problem
(you need to supply an input file "mtfile" of sufficient size).
I'm using "wish81", not tclsh81.  "wish80" from the 8.0 Tcl release works fine.

Hopefully someone will use this to verify that the next release corrects
the problem.  In the meantime, does anyone know whether there is currently
a patch that will fix this?

Thanks ...

-- [email protected]

# START OF TCL CODE
proc getdata {file} {
        set fd [open $file]
        set rs [read $fd]
        close $fd
        return $rs
}

proc parse {html {cmd xtk_HMtest_parse} {start hmstart}} {
        regsub -all \{ $html {\&ob;} html
        regsub -all \} $html {\&cb;} html
        set w " \t\r\n" ;# white space
        proc xtk_HMcl x {return "\[$x\]"}
        set exp <(/?)([xtk_HMcl ^$w>]+)[xtk_HMcl $w]*([xtk_HMcl ^>]*)>
        set sub "\}\n$cmd {\\2} {\\1} {\\3} \{"
        regsub -all $exp $html $sub html
        eval "$cmd {$start} {} {} \{ $html \}"
        eval "$cmd {$start} / {} {}"
}

proc xtk_HMtest_parse {command tag slash text_after_tag} {
    puts -nonewline "."
    #puts "==> $command $tag $slash $text_after_tag"
}

proc doit {file} {
        set data [getdata $file]
        puts "size=[string length $data]"
        parse "$data"
}

doit myfile

----------

More info:
First, I forgot to mention that I'm running Tcl 8.1a2 on Window NT 4.0.
Second, I've discovered that this program only fails when the input file
contains particular data.  In other words, you can't reproduce the problem
with any aritrary large file ... my file contains HTML, and some of the
"regsub" commands process it.  So the "regsub" command must be involved in
the problem somehow.
If someone wants it, I'll gladly provide my data file which is needed to
reproduce the problem (but is anyone really fixing bugs now?)

-- [email protected]

Some worst case regexp bugs were fixed in the 8.2b3 release. 
-- 08/13/1999 hobbs
welch Closed ticket [218466ffff]. [History diff]2000-10-26 08:22:17
dgp Ticket [218466ffff]: 3 changes [History diff]2001-04-17 04:22:32
Log in (anonymous is fine) to add a comment.