Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f2917dab5ce354f9f7cea05976f851fcb3f8be0f
Ticket: 456892ffffffffffffffffffffffffffffffffff
Tcl_AppendStringsToObj -> abort
User & Date: msofer on 2001-08-31 08:33:55
Changes

  1. icomment:
    Logged In: YES 
    user_id=148712
    
    This seems to be an unfortunate combination of two semi-bugs
    (aka
    optimisations?): 
      
    1 - TclCompileScript (tclCompile.c, ll. 838) just POPs the
    previous
    command result from the stack but does not reset the
    interp's
    result. This is OK as (in principle) bcc'ed commands
    communicate their  
    results on the stack and do not set the interp's result.
    Compare this
    to clearing the result before each invocation of a command
    or
    evaluation of a script.
    
    2 - Some error messages are *appended* to the interp's
    result. This is
    necessary for the buildup of the error call stack, but I
    think the
    interp's result should be reset by the error *originators*
    (in these
    examples, TclGetIntForIndex) before appending.
    
    I would say that #2 should be hunted down, #1 is valuable.
    As a
    general rule, commands and functions should not assume that
    they get
    an empty result when they are called; they should set the
    result, not
    append to it.
    
    -----
    Additionally:
    "set r [list]" triggers a core dump because it leaves a
    shared object
    in the interp's result: the same object is the value of r.
    The
    following function behaves correctly
    
    proc tst2 {} {
        set r r[list]
        lindex a a
    }
    
    Note that if you *force* other commands to communicate via
    the interp's 
    result, you reproduce the behaviour: the following dumps
    core too
    
    proc tst3 {} {
        set set set
        $set r 5
        lindex a a
    }
    
    ----
    IN CONCLUSION:
    
    (a) this particular bug is fixed by resetting the interp's
    result in
    TclGetIntForIndex. 
    
    (b) there may be other similar bugs lurking in the
    background, waiting
    to trip the unwary; a hunt for functions abusingly appending
    to the
    result without first resetting it first should be done.
    
    
    
  2. login: "msofer"
  3. mimetype: "text/plain"
  4. username: "msofer"