Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 017ca883f6956f064ccdf955beb0168646197ffa
Ticket: bb6108bb671bb697f10466325e4e9c612831b544
Array tracing not as documented
User & Date: ehunter on 2015-10-04 17:41:06
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    I have found some probable issues with variable tracing of arrays.
    
    The following example seems to cause incorrect recursion of tracing
    It also results in a final read value that does not include the changes that occured during tracing.
    
    
    Program:
    
    # Setup
    set y(bar) 1
    trace variable y r { puts "in trace2 reading y     "; puts  [array get y]  ; puts "end trace2" ;#} 
    trace variable y r { puts "in trace1 set   y(foo) 1"; set y(foo) 1         ; puts "end trace1" ;#} 
    
    # when running the following command, traces get run in reverse order of creation - i.e. trace1, then trace2
    # On entry to the command, y is ( bar=>1 )
    # trace1 should get called setting y(foo) to 1  which results in y ( bar=>1, foo=>1 ) 
    # trace2 should then run:
    #          it unsets y(bar) which results in y ( foo=>1 )
    #          it then reads elements of y, however as per the documentation, traces on y are currently disabled during execution of this trace handler. Hence this read should solely result in printing "foo 1"
    # No more tracing should occur
    
    puts "y = [array get y]"
    
    # What actually happens:
    # 	trace1 is called setting y(foo) to 1 which results in y ( bar=>1, foo=>1 )
    #   trace2 is called:
    #            it reads y using "array get" command
    #            trace1 is incorrectly triggered again - it should have been currently disabled, value of y does not change
    #            trace2 is incorrectly triggered again - 
    #                                  it reads y using "array get" command again - this time the trace recursion seems to be correctly disabled.
    #                                  prints values of y "foo 1 bar 1" - value is as expected
    #                                  repeated trace2 ends
    #            prints values of y "foo 1 bar 1" - as expected
    #            repeated trace2 ends
    #
    #   print which triggered the tracing prints wrong value "y = bar 1"  - should be "y = foo 1 bar 1"
    
    
    Actual output:
    
    in trace1 set   y(foo) 1                                                                                                                                                                                                                               
    end trace1                                                                                                                                                                                                                                             
    in trace2 reading y                                                                                                                                                                                                                                    
    in trace1 set   y(foo) 1                                                                                                                                                                                                                               
    end trace1                                                                                                                                                                                                                                             
    in trace2 reading y                                                                                                                                                                                                                                    
    foo 1 bar 1                                                                                                                                                                                                                                            
    end trace2                                                                                                                                                                                                                                             
    foo 1 bar 1                                                                                                                                                                                                                                            
    end trace2                                                                                                                                                                                                                                             
    y = bar 1  
    
    
    
    Regards,
    
    Evan Hunter
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "ehunter"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "135c9fb5ee475eef7f60cf82448c359ece8a103e"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "ehunter"
  14. subsystem changed to: "46. Traces"
  15. title changed to: "Array tracing not as documented"
  16. type changed to: "Bug"