Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8c313df77492a149a914ae939b68ce352cc41db3
Ticket: 771613ffffffffffffffffffffffffffffffffff
Incorrect if syntax crashes tcl
User & Date: nobody on 2003-07-15 13:52:42
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OS platform: linux 2.4.20, glibc 2.3.2, gcc 3.2.2
    Problem behaviour:
    Incorrect syntax for the if command, where the body
    opening brace is on the next line rather than the same
    line as the
    if command, causes the interpreter to crash.
    In the sample code below, the barcode_* functions are just 
    supporting functions from the program which exhibited
    the problem. 
    I reduced it down as far as I could. I note that if I
    do not call
    barcode_scanner_parm_get in the if expression, but
    replace it
    with something like 0 == 0, the crash does not occur.
    To reproduce the problem, save the following code to a
    file,
    test.tcl, and issue the command:
    tclsh test.tcl
    A stack trace is also included below.
    Expected behaviour:
    Show syntax error message but do not crash.
    Code sample:
    ------snip--------
    proc barcode_scanner_parm_get {scanner parm} {
        global barcode_scanner
        if {[array get barcode_scanner $scanner,$parm] == ""} {
    return 0
        }
        return $barcode_scanner($scanner,$parm)
    }
    
    proc barcode_scanner_parm_set {scanner parm val} {
        global barcode_scanner
        array set barcode_scanner "$scanner,$parm $val"
    }
    
    proc barcode_scanner_exists {scanner} {
        global barcode_scanner
        if {[array get barcode_scanner $scanner,mode] != ""} {
    return 1
        } else {
    return 0
        }
    }
    
    proc barcode_scanner_init {scanner} {
        barcode_scanner_parm_set $scanner mode normal
        barcode_scanner_parm_set $scanner state idle
    }
    
    proc test {} {
        set scanner 1
        if {![barcode_scanner_exists $scanner]} {
    barcode_scanner_init $scanner
        }
        
        if {[barcode_scanner_parm_get $scanner log_id] != 0} {
    if {[barcode_scanner_parm_get $scanner workorder] == 0 &&
        [barcode_scanner_parm_get $scanner workorder] == 0}
    {
        rpc_return fail barcode-sequence no-workorder {}
    }
    set result [action_log_process_stop \
    [barcode_scanner_parm_get $scanner log_id]]
        }
    }
    
    test
    ------snip--------
    
    #0  0x42073499 in free () from /lib/tls/libc.so.6
    #1  0x400f4437 in TclpFree () from
    /usr/local/lib/libtcl8.4.so
    #2  0x400fa5bd in Tcl_Free () from
    /usr/local/lib/libtcl8.4.so
    #3  0x401107f6 in TclFreeJumpFixupArray () from
    /usr/local/lib/libtcl8.4.so
    #4  0x4010906f in TclCompileIfCmd () from
    /usr/local/lib/libtcl8.4.so
    #5  0x4010e995 in TclCompileScript () from
    /usr/local/lib/libtcl8.4.so
    #6  0x4010fa4b in TclCompileCmdWord () from
    /usr/local/lib/libtcl8.4.so
    #7  0x40108bb6 in TclCompileIfCmd () from
    /usr/local/lib/libtcl8.4.so
    #8  0x4010e995 in TclCompileScript () from
    /usr/local/lib/libtcl8.4.so
    #9  0x4010e28e in TclSetByteCodeFromAny () from
    /usr/local/lib/libtcl8.4.so
    #10 0x4010e417 in SetByteCodeFromAny () from
    /usr/local/lib/libtcl8.4.so
    #11 0x40116fc3 in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #12 0x400f7474 in Tcl_EvalObjEx () from
    /usr/local/lib/libtcl8.4.so
    #13 0x401046a8 in Tcl_SwitchObjCmd () from
    /usr/local/lib/libtcl8.4.so
    #14 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #15 0x401179ab in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #16 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #17 0x40141bea in TclObjInterpProc () from
    /usr/local/lib/libtcl8.4.so
    #18 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #19 0x400f6f5d in Tcl_EvalEx () from
    /usr/local/lib/libtcl8.4.so
    #20 0x400f7447 in Tcl_EvalObjEx () from
    /usr/local/lib/libtcl8.4.so
    #21 0x401415ed in Tcl_UplevelObjCmd () from
    /usr/local/lib/libtcl8.4.so
    #22 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    ---Type <return> to continue, or q <return> to quit---
    #23 0x401179ab in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #24 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #25 0x40117a50 in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #26 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #27 0x40141bea in TclObjInterpProc () from
    /usr/local/lib/libtcl8.4.so
    #28 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #29 0x400f6f5d in Tcl_EvalEx () from
    /usr/local/lib/libtcl8.4.so
    #30 0x40147417 in AfterProc () from
    /usr/local/lib/libtcl8.4.so
    #31 0x40146cc7 in TclServiceIdle () from
    /usr/local/lib/libtcl8.4.so
    #32 0x40138d96 in Tcl_DoOneEvent () from
    /usr/local/lib/libtcl8.4.so
    #33 0x4011668a in Tcl_VwaitObjCmd () from
    /usr/local/lib/libtcl8.4.so
    #34 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #35 0x401179ab in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #36 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #37 0x400f7474 in Tcl_EvalObjEx () from
    /usr/local/lib/libtcl8.4.so
    #38 0x400fdb3d in Tcl_IfObjCmd () from
    /usr/local/lib/libtcl8.4.so
    #39 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #40 0x400f6f5d in Tcl_EvalEx () from
    /usr/local/lib/libtcl8.4.so
    #41 0x400f7447 in Tcl_EvalObjEx () from
    /usr/local/lib/libtcl8.4.so
    #42 0x400fb400 in Tcl_EvalObjCmd () from
    /usr/local/lib/libtcl8.4.so
    #43 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #44 0x401179ab in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #45 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    ---Type <return> to continue, or q <return> to quit---
    #46 0x40141bea in TclObjInterpProc () from
    /usr/local/lib/libtcl8.4.so
    #47 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #48 0x401179ab in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #49 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #50 0x40141bea in TclObjInterpProc () from
    /usr/local/lib/libtcl8.4.so
    #51 0x400f668d in TclEvalObjvInternal () from
    /usr/local/lib/libtcl8.4.so
    #52 0x401179ab in TclExecuteByteCode () from
    /usr/local/lib/libtcl8.4.so
    #53 0x4011706b in TclCompEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #54 0x400f7474 in Tcl_EvalObjEx () from
    /usr/local/lib/libtcl8.4.so
    #55 0x40122d3f in Tcl_RecordAndEvalObj () from
    /usr/local/lib/libtcl8.4.so
    #56 0x40122c27 in Tcl_RecordAndEval () from
    /usr/local/lib/libtcl8.4.so
    #57 0x400472fd in StdinProc () from
    /usr/local/lib/libtk8.4.so
    #58 0x4012a09f in Tcl_NotifyChannel () from
    /usr/local/lib/libtcl8.4.so
    #59 0x4015598a in FileHandlerEventProc () from
    /usr/local/lib/libtcl8.4.so
    #60 0x40138a64 in Tcl_ServiceEvent () from
    /usr/local/lib/libtcl8.4.so
    #61 0x40138d7e in Tcl_DoOneEvent () from
    /usr/local/lib/libtcl8.4.so
    #62 0x4003bf33 in Tk_MainLoop () from
    /usr/local/lib/libtk8.4.so
    #63 0x4004718b in Tk_MainEx () from
    /usr/local/lib/libtk8.4.so
    #64 0x080487f1 in main ()
    #65 0x42015574 in __libc_start_main () from
    /lib/tls/libc.so.6
    
    
  4. foundin changed to: "obsolete: 8.4.3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "45. Parsing and Eval"
  10. title changed to: "Incorrect if syntax crashes tcl"
  11. type changed to: "Bug"