Skip to content
Tcl Source Code History Of Ticket 5808081213
Login

History Of Ticket 5808081213

Artifacts Associated With Ticket 5808081213

  1. Ticket change [472ed9835f] (rid 158868) by tomkiti on 2017-11-22 15:44:55:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      When "string length" is traced, it converts a bytearray argument to a string. This happens when the the trace operation is either enterstep or leavestep, but not enter or leave. This behavior does not occur in Tcl 8.5.
      
      Script:
      
          proc p {} {
              set x [binary format x]
              puts [::tcl::unsupported::representation $x]
              string length $x
              puts [::tcl::unsupported::representation $x]
          }
          
          proc traceProc {args} {}
          
          trace add execution p enterstep traceProc
          p
      
      Output:
          value is a bytearray with a refcount of 2, object pointer at 00000000003847A0, internal representation 0000000000399860:0000000000384740, string representation " "
          value is a string with a refcount of 2, object pointer at 00000000003847A0, internal representation 000000000039AF40:0000000000384740, string representation " "
      
    5. foundin initialized to: "8.6.7"
    6. is_private initialized to: "0"
    7. login: "tomkiti"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "1c57e67924247fd7926e89348f266c081ec57db2"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "tomkiti"
    14. subsystem initialized to: "12. ByteArray Object"
    15. title initialized to:
      "string length" converts bytearrays to strings when traced
      
    16. type initialized to: "Bug"
  2. Ticket change [3449772d21] (rid 159112) by dgp on 2017-11-30 15:51:36:

    1. icomment:
      
      You're seeing a difference between bytecompiled [string length] and direct eval [string length] because tracing prevents compiling of proc bodies.
      
      This is fixed in 8.7a where the multiple [string length] implementations have all been refactored into a single common routine.
      
      That refactoring could conceivably be backported to the 8.6 branch, with the usual risk/reward dilemma.  My gut says don't do it, since we don't make shimmering promises anyway, but my feelings aren't set in stone.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  3. Ticket change [db6739393d] (rid 159121) by dgp on 2017-11-30 16:07:56:

    1. icomment:
      
      Well, that was a nice theory, but it's false. stay tuned.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [200c019536] (rid 159123) by dgp on 2017-11-30 16:14:02:

    1. icomment:
      
      The tracing forces generation of a string rep.
      
      After the string rep is generated, the bytearray is no longer "pure" so it becomes worthless (Insert Standard Rant here), and can no longer take optimized paths in Tcl_GetCharLength() to prevent the shimmer to "string" type.
      
      In this particular case, the string in question is the empty string.
      
      The misbehavior does not happen in Tcl 8.7 because an additional optimization for strings of less than 2 bytes has been added.  I have no qualms about backporting that small, obviously correct bit of code.
      
      See dgp-properbytearry branch for work toward making ByteArrays not be broken as designed anymore, but that's a Tcl 9 fix.
      
      All that said, it's also possible that the defects of non-pure bytearray values don't actually get in the way of getting a correct value out of Tcl_GetCharLength().
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [d258b1ae0c] (rid 159130) by dgp on 2017-11-30 16:22:23:

    1. icomment:
      
      Sorry again. we're not working with an empty string, but a string of 1 NUL character, which has a two-byte string rep.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  6. Ticket change [1b6efc93f6] (rid 159131) by dgp on 2017-11-30 16:24:51:

    1. icomment:
      
      The misbehavior is fixed in 8.7a because the partial work un-breaking ByteArrays is already done there, and for this particular problem, that is enough.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  7. Ticket change [49d3b84bf2] (rid 159132) by sebres on 2017-11-30 17:08:49:

    1. icomment:
      > After the string rep is generated, the bytearray is no longer "pure" so it becomes worthless 
      
      That's why I always said: we need by byte-arrays the same flag like "canonical" by lists.
      The current "pure" solution works only until the first time the string representation is built.
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  8. Ticket change [a1153d5a20] (rid 159137) by dgp on 2017-11-30 17:11:33:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2458088.21635568"
    3. closer changed to: "dgp"
    4. icomment: "Fixed for 8.6.8."
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
  9. Ticket change [24c8087c67] (rid 159138) by dgp on 2017-11-30 17:13:50:

    1. closedate changed to: "2458088.21794448"
    2. icomment:
      
      sebres, the 8.7 solution is a new Tcl_ObjType that properly records bytearrays only for values that are sequences of bytes.
      
      The completion of the solution is taking shape on the dgp-properbytearray branch, to be merged to trunk/9.0 after TIP approval.
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  10. Ticket change [7a2d36bdcc] (rid 159142) by sebres on 2017-11-30 17:33:12:

    1. closedate changed to: "2458088.23139542"
    2. closer changed to: "sebres"
    3. icomment:
      > The completion of the solution is taking shape on the dgp-properbytearray branch...
      
      I know, but ...
      
      > to be merged to trunk/9.0 after TIP approval.
      
      This meant almost "never" (well rather said "too late" in production), if we look how fast the new things are released.
      
    4. login: "sebres"
    5. mimetype: "text/plain"