Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-19
03:21 • Ticket [218918ffff] regsub commands causes core dump status still Closed wit... artifact: 43bfe0438f user: dgp
2000-10-26
08:31 • Closed ticket [218918ffff]. artifact: fcab7df3e9 user: welch
01:07 • New ticket [218918ffff]. artifact: 2038282811 user: nobody

regsub commands causes core dump

Closed / Fixed218918ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:07:52
OriginalBugID: 2723 Bug
Version: 8.2
SubmitDate: '1999-09-10'
LastModified: '1999-09-10'
Severity: CRIT
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: SunOS
OSVersion: All other platforms are affetced as well
Machine: Sparc
FixedDate: '1999-09-10'
FixedInVersion: 8.2.1
ClosedDate: '2000-10-25'


Name:
Wolfgang S. Kechel

Comments:
Error happens only when regsub command is used with wrong replacement
    spec.

ReproducibleScript:
regsub scene- scene-push {win-\1} winproc
    
    I know this spec is wrong, but it should not cause memory corruption or
    core-dumps.
    The correct command is:
    regsub {scene-(.+)} scene-push {win-\1} winproc;

ObservedBehavior:
The code in Tcl_RegSubObjCmd line 490, the indexed match 1 is used in
        subStart = info.matches[index].start;
        subEnd = info.matches[index].end;
    for \1 in the substitution spec, but there is not first match. So memory
    is
    dereferenced that should not be referenced and a portion of data is
    appended
    to the result that has nothing to do with the command parameters. It
    happens,
    that due to the values stored in the memory area chunk of 80MB or even
    larger might be copied into the result, the chunks may become to big for
    malloc and
    cause a core dump.
    
    into the result or

DesiredBehavior:
I expect the regsub command to issue an error when no match for a \Digit
    spec
    is present in the source string (like Emacs does it)!



I have fixed
this for the next release to just default to null, which is the same
behavior that Perl and Emacs have. 
-- 09/10/1999 hobbs
welch Closed ticket [218918ffff]. [History diff]2000-10-26 08:31:16
dgp Ticket [218918ffff]: 3 changes [History diff]2001-04-19 03:21:52
Log in (anonymous is fine) to add a comment.