Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dcacc925919290b1fb629f7b82873a764b62e48c
Ticket: bc1a96407a7f73024c2238a747b428ec1145ae19
segfault in compiled [array set] of array-traced variable
User & Date: dkf on 2014-09-09 20:10:08
Changes

  1. icomment:
    The code generated in this case is (removing wholly irrelevant bits):
    <pre>
      Command 5: "array set ::guggus  [list a 1 b 2]"...
        (30) startCommand +86 1 	# next cmd at pc 116
        (39) push1 3 	# "::guggus"
        (41) push1 4 	# "0"
        (43) reverse 2 
    <span style="background:#eaeaff">    (48) upvar %v2 	# temp var 2</span>
        (53) pop 
      Command 6: "list a 1 b 2"...
        (54) startCommand +14 1 	# next cmd at pc 68
        (63) push1 5 	# "a 1 b 2"
        (65) dup 
        (66) listLength 
        (67) pop 
        (68) dup 
        (69) listLength 
        (70) push1 6 	# "1"
        (72) bitand 
        (73) jumpFalse1 +15 	# pc 88
        (75) push1 7 	# "list must have an even number of element"...
        (77) push1 8 	# "-errorcode {TCL ARGUMENT FORMAT}"
        (79) returnImm +1 0 
        (88) arrayExistsImm 2 
        (93) jumpTrue1 +7 	# pc 100
        (95) arrayMakeImm 2 
        (100) foreach_start 0 
    		[data=[%v1633771873], loop=%v18446744073709551609
    		 it%v1633771873	[%v3, %v4]]
        (105) loadScalar1 %v3 	# temp var 3
        (107) loadScalar1 %v4 	# temp var 4
    <span style="background:#eaeaff">    (109) storeArray1 %v2 	# temp var 2</span>
        (111) pop 
        (112) foreach_step 
        (113) foreach_end 
        (114) push1 1 	# ""
    </pre>
    I do not remember using <tt>upvar</tt> when writing the <tt>array set</tt> compiler. But be that as it may, <b>if</b> we fix this by generating the loop with <tt>storeArrayStk</tt>, we need to be careful when changing this (particularly the code that generates the highlighted lines) to ensure that we only run the code to generate the array name once; that'll have to be the value stored in the temporary variable.
    <p>
    Can we make the solution with nameless aliases work instead? Please? It's so much easier to code correctly.
    
  2. login: "dkf"
  3. mimetype: "text/html"
  4. username: "dkf"