#2410 Incorrect if syntax crashes tcl

obsolete: 8.4.3
closed-fixed
Don Porter
9
2003-07-15
2003-07-15
Anonymous
No

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

Discussion

  • miguel sofer
    miguel sofer
    2003-07-15

    Logged In: YES
    user_id=148712

    Contact info: submitted by alias mb in the tcl'ers chat
    (contact data there, I will not replicate it here without
    mb's permission)

     
  • miguel sofer
    miguel sofer
    2003-07-15

    Logged In: YES
    user_id=148712

    Crash confirmed, case reduced to

    proc test {} {
    if {[someLongNameIsApparentlyNecessary]
    &&[longNamePossiblyNotTheSame]}
    }
    test

     
  • miguel sofer
    miguel sofer
    2003-07-15

    • priority: 5 --> 9
     
  • Don Porter
    Don Porter
    2003-07-15

    Logged In: YES
    user_id=80530

    making no progress tracking this
    down. It's a Heisenbug that
    goes away when I enable symbols.

    nasty memory corruption somewhere.

     
  • Don Porter
    Don Porter
    2003-07-15

    Logged In: YES
    user_id=80530

    FWIW, I can only reproduce
    the crash on Solaris using
    the original demo script, not
    the reduced one.

    Furthermore, the crash only
    shows up for Tcl 8.4.3 and
    the tip of the core-8-4-branch.
    Releases, Tcl 8.4.0, 8.4.1, 8.4.2
    do not crash.

    That may or may not be meaningful.

     
  • Jeffrey Hobbs
    Jeffrey Hobbs
    2003-07-15

    • assigned_to: msofer --> dgp
     
  • Jeffrey Hobbs
    Jeffrey Hobbs
    2003-07-15

    Logged In: YES
    user_id=72656

    bug introduced by 711371 fix. Assigning to dgp to correct.

     
  • Don Porter
    Don Porter
    2003-07-15

    • status: open --> closed-fixed
     
  • Don Porter
    Don Porter
    2003-07-15

    Logged In: YES
    user_id=80530

    fix is attached patch, now committed
    to core-8-4-branch and HEAD.

    If testing fails, please re-open this bug.

     
  • Don Porter
    Don Porter
    2003-07-15

     
    Attachments