Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#3318 invalid object modification

obsolete: 8.5a3
closed-duplicate
miguel sofer
5
2005-12-07
2005-12-06
Ulrich Ring
No

(1) run the following script:

proc touch {listValue} {
lset listValue 1 4 5
return $listValue
}
set data [list a [list 1 2 3] b]
puts $data
touch $data
puts $data

(2) you get the expected output:

a {1 2 3} b
a {1 2 3} b

... the proc "touch" has _not_ changed the variable
"data"

(3) now uncomment the first "puts $data" command and
rerun the script

(4) the output is

a {1 7 3} b

BTW: This does _not_ happen with tcl8.5a2.

Discussion

  • miguel sofer
    miguel sofer
    2005-12-06

    • assigned_to: nijtmans --> msofer
     
  • miguel sofer
    miguel sofer
    2005-12-06

    Logged In: YES
    user_id=148712

    Something is wrong in your description:

    mig@uhu:/home/CVS/tcl_SF_clean/unix$ cat /tmp/test0
    proc touch {listValue} {
    lset listValue 1 4 5
    return $listValue
    }
    set data [list a [list 1 2 3] b]
    puts $data
    touch $data
    puts $data
    mig@uhu:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test0
    a {1 2 3} b
    list index out of range
    while executing
    "lset listValue 1 4 5"
    (procedure "touch" line 2)
    invoked from within
    "touch $data"
    (file "/tmp/test0" line 7)

     
  • Ulrich Ring
    Ulrich Ring
    2005-12-06

    Logged In: YES
    user_id=123371

    oops. the command in proc touch must read:

    lset listValue 1 1 7

    sorry;

     
  • miguel sofer
    miguel sofer
    2005-12-06

    Logged In: YES
    user_id=148712

    I cannot reproduce the bug here; am I following your
    instructions correctly?

    mig@uhu:/home/CVS/tcl_SF_clean/unix$ cat /tmp/test0
    proc touch {listValue} {
    lset listValue 1 1 7
    return $listValue
    }
    set data [list a [list 1 2 3] b]
    puts $data
    touch $data
    puts $data
    mig@uhu:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test0
    a {1 2 3} b
    a {1 2 3} b
    mig@uhu:/home/CVS/tcl_SF_clean/unix$ cat /tmp/test1
    proc touch {listValue} {
    lset listValue 1 1 7
    return $listValue
    }
    set data [list a [list 1 2 3] b]
    #puts $data
    touch $data
    puts $data
    mig@uhu:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test1
    a {1 2 3} b

     
  • Ulrich Ring
    Ulrich Ring
    2005-12-06

    Logged In: YES
    user_id=123371

    > I cannot reproduce the bug here; am I following your
    > instructions correctly?

    Your approach is perfect.

    On our sites the version of TCL matters.

    [info patchlevel] should report something >=8.5a3

    We can reproduce the bug on:

    linux - gcc 2.95.x
    linux - gcc 3.3.x
    windows VC7

    I even checked the "latest" snapshot ( actually
    it was of yesterday ).

    If you can't reproduce the bug, what can we do to
    give you more precise information?

     
  • miguel sofer
    miguel sofer
    2005-12-06

    Logged In: YES
    user_id=148712

    Neither I nor 4 other core maintainers could repro this bug.

    Let me give you some questions and homework to try to narrow
    it down.

    (1) these is obviously self-compiled tclsh; what compile
    flags did you use?

    (2) Did you run 'make install'? (not necessary if
    --disable-shared passed to ./configure)

    (3) Is your tclsh linked with any custom C code, or using
    extensions?

    (4) Are you running this at the command line? Could the
    a {1 7 3} b
    just be the return value of [touch] being output to the
    console? Or do you see this effect when running in batch mode?

    (5) Please repro what I did and confirm that you get
    different results:
    cd path/to/Tcl/unix
    make distclean
    ./configure --disable-shared
    make
    ...
    ./tclsh path/to/test0
    ...
    ./tclsh path/to/test1

     
  • miguel sofer
    miguel sofer
    2005-12-06

    • status: open --> pending-works-for-me
     
  • Ulrich Ring
    Ulrich Ring
    2005-12-06

    Logged In: YES
    user_id=123371

    No custom code, pure tcl.

    Well, it's embarassing, since I've no idea what's going
    on.

    I just ran the following script:

    mkdir /tmp/tcltest
    cd /tmp/tcltest

    tar zxvf /archiv/tcl/tcl8.5a3-src.tar.gz
    cd tcl8.5a3/unix

    ./configure --disable-shared
    make

    ./tclsh /tmp/test0

    ./tclsh /tmp/test1

    ...and could repro the misbehaviour.

    i.e.

    - no custom tclsh
    - no custom extensions

    Well, tomorrow I'll go to think about how
    to improve the documentation of the facts
    we're observing.

     
  • Ulrich Ring
    Ulrich Ring
    2005-12-06

    • status: pending-works-for-me --> open-works-for-me
     
  • miguel sofer
    miguel sofer
    2005-12-06

    • status: open-works-for-me --> open
     
  • miguel sofer
    miguel sofer
    2005-12-06

    Logged In: YES
    user_id=148712

    AHA! Repro succesfull with 8.5a3!

    It looks like a bug that has been fixed in HEAD. Could you
    verify with a current tclsh? My impression is that this is
    another aspect of Bug #1333036, fixed on 2005-10-20.

    PS: cvs nightly snapshots at
    ftp://www.tcl.tk/pub/tcl/nightly-cvs/

     
  • Ulrich Ring
    Ulrich Ring
    2005-12-07

    Logged In: YES
    user_id=123371

    Well, I checked out tcl-20051205
    from ftp://www.tcl.tk/pub/tcl/nightly-cvs/

    Things are OK now.

    Thanks a lot.

     
  • miguel sofer
    miguel sofer
    2005-12-07

    • status: open --> closed-duplicate