Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 29958c27be56a4b52253f4bfa195a33ff2b527a0e501ac76f9593ac6df93a198
Ticket: 56ab601b7dfd649035e808fb85e024f60e02e280
Canonical sign becomes wrong after list duplication resp. botched after build of string representation of the copy.
User & Date: sebres on 2018-03-14 21:11:45
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    If we've an object with definitely not canonical form of string representation, 
    for example `originPtr` with string content like `a   b`, so any in-place 
    conversion of this object to the list set the canonicalFlag of the new created
    internal list representation to 0.
    So far, everything is OK.
    
    Now something like TclListObjCopy, DupListInternalRep, etc, that just copies 
    the internal representation of this list, will be executed, so we have another 
    object `copyPtr` with the same internal list representation as `originPtr` (with 
    List::refCount == 2 now).
    
    The canonicalFlag is still correct, but evil is already happened.
    
    Because after call of something expected string representation for this duplicate
    `copyPtr` (that calls UpdateStringOfList), the canonicalFlag of the list of this
    object gets 1 (actually of both objects)!
    
    The problem is - this list representation is "shared" between `originPtr` and 
    `copyPtr`, thus the check using ListObjIsCanonical(originPtr) return 1 now.
    
    The issue is basically present because the member canonicalFlag must belong not 
    to the List structure, but to the Tcl_Obj (e. g. as second int-rep like flags in 
    internalRep.ptrAndLongRep.value, so can be different across `originPtr` and 
    `copyPtr` with the same "shared" internal list representation.
    
    Unfortunately it changes the structure of the list (and macros), so not really backwards compatible (at least not for compiled binaries). 
    But IMHO this is the proper way only, to fix this issue.
    
  5. foundin changed to: "all"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Important"
  11. status changed to: "Open"
  12. submitter changed to: "sebres"
  13. subsystem changed to: "14. List Object"
  14. title changed to:
    Canonical sign becomes wrong after list duplication resp. botched after build of string representation of the copy.
    
  15. type changed to: "Bug"