Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2000-10-26
08:28 • Closed ticket [218775ffff]: Segfault in large pgm with large no. of scalar globa... artifact: 2194e11c5f user: welch
01:05 • New ticket [218775ffff]. artifact: 213f74eb04 user: nobody

Segfault in large pgm with large no. of scalar globals

Closed / Fixed218775ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:05:13
OriginalBugID: 2092 Bug
Version: 8.1
SubmitDate: '1999-05-18'
LastModified: '1999-11-08'
Severity: CRIT
Status: Released
Submitter: pat
ChangedBy: hobbs
OS: Linux
OSVersion: 2.2.1
Machine: Other
FixedDate: '1999-11-08'
FixedInVersion: 8.2.2
ClosedDate: '2000-10-25'


Name:
Robert Woodside

ReproducibleScript:
It can't be done with a short script - it appears to require quite a
    large program containng a large number of scalar global vars - see
    description below.

ObservedBehavior:
I am getting bug reports that my popular shareware offering, TkZip,
    causes the Tcl interpreter to segfault with the new 8.1 release. (I
    have
    reports specifically on SGI and Linux systems so far.)
    
    The bug seems to have to do with a very large program containing a
    large number of global scalar variables.
    
    Unfortunately, I have been unable to cause this to occur with a small,
    manageable snippet of code - it seems to require a rather large program
    
    
    The program is rather too large to include inline (682K); however, it
    can be fetched from the TkZip home page at
    http://www.pcnet.com/~proteus/TkZip.
    Version 1.0.8 (http://www.pcnet.com/~proteus/TkZip/TkZip-1.0.8.tar.gz)
    is the
    one that segfaults; I will leave it there for a while; I have released a
    1.0.9
    version which has a workaround for the problem.
    
                 ------------------------------------------------------
    
    Here is what happens with version 1.0.8 under Tcl 8.1. The segfault
    occurs at line 436 in TkZip, which reads:
    
    > catch {puts $si "\n================\nXserver probe response:\n
    $tmp\n================\n"}
    
    The error has nothing to do with this line of code, however, A stack
    trace
    shows the following:
    
    > #0  0x402c4ede in strlen (str=0x804a030 "|¡\004\b")
    > (gdb) bt
    > #0  0x402c4ede in strlen (str=0x804a030 "|¡\004\b")
    > #1  0x818d900 in ?? ()
    > #2  0x4016bbf8 in Tcl_AppendResult (arg1=0x804a030)
    >     at ./../generic/tclResult.c:543
    > #3  0x40177dd1 in VarErrMsg (interp=0x804a030, part1=0x21 "7",
    part2=0x0,
    >     operation=0x40189ff8 "read", reason=0x40189ef1 "variable is
    array")
    >     at ./../generic/tclVar.c:4649
    > #4  0x40173a37 in TclGetIndexedScalar (interp=0x804a030,
    localIndex=-124,
    >     leaveErrorMsg=1) at ./../generic/tclVar.c:766
    > #5  0x40137776 in TclExecuteByteCode (interp=0x804a030,
    codePtr=0x8196e70)
    >     at ./../generic/tclExecute.c:1070
    > #6  0x40113c9a in Tcl_EvalObjEx (interp=0x804a030, objPtr=0x807f1c0,
    flags=0)
    >     at ./../generic/tclBasic.c:2699
    > #7  0x40169c97 in TclObjInterpProc (clientData=0x8051b40,
    interp=0x804a030,
    >     objc=1, objv=0xbfffee40) at ./../generic/tclProc.c:995
    > #8  0x4016089f in EvalObjv (interp=0x804a030, objc=1,
    objv=0xbfffee40,
    >     command=0x404a94d2 "\n\n\n\n#", '-' <repeats 30 times>, "\n#
    Here's the real
    >  program...\n#   Not very impressive, huh?\n#", '-' <repeats 30
    times>, "\n\nIni
    > t\nBuildMainFrame\n# If cmd line arg specified a file, open up a
    window"...,
    >     length=428, flags=0) at ./../generic/tclParse.c:923
    > #9  0x401611a8 in Tcl_EvalEx (interp=0x804a030,
    >     script=0x403ff008 "#!/bin/sh\n# the next line restarts using wish
    \\\nexec w
    > ish \"$0\" \"$@\"\n#  TkZip  Copyright © 1996, 1998 by Robert
    Woodside.\n#  A T
    > k/Tcl program for managing zipped & tarred archives\n\n#", '-'
    <repeats 18 times
    > >..., numBytes=697974, flags=0) at ./../generic/tclParse.c:1384
    > #10 0x40155e3f in Tcl_EvalFile (interp=0x804a030,
    >     fileName=0xbffff26c "./TkZipt") at ./../generic/tclIOUtil.c:323
    > #11 0x4003face in Tk_MainEx (argc=1, argv=0xbffff3a8,
    >     appInitProc=0x804881c <Tcl_AppInit>, interp=0x804a030)
    >     at ./../generic/tkMain.c:229
    > #12 0x804880e in main (argc=2, argv=0xbffff3a4) at ./tkAppInit.c:54
    > #13 0x804874e in ___crt_dummy__ ()
    > (gdb)                  
    
    The "error" being reported in VarErrMsg is clearly bogus, and the
    interpreter
    has got its addressability messed up somewhere prior to this.
    
    Over several years of "feeping creaturism", the program had acquired
    a very large number of global scalar variables, and most of the code
    prior to
    this point is just initializing them. I found that if I mashed about 40
    or so
    of them into one indexed array, the problem went away, so I embarked on
    a major
    code cleanup as a workaround.
    
    If you need any additional information, please don't hesitate to
    contact me.

DesiredBehavior:
Um...I'd expect to see the Tcl interpreter not segfault, or try to
    report bogus errors.



Fixed in 8.2.[12]. 
-- 11/08/1999 hobbs
welch Closed ticket [218775ffff]. [History diff]2000-10-26 08:28:15
Log in (anonymous is fine) to add a comment.