Skip to content
Tcl Source Code History Of Ticket 0306a5563c
Login

History Of Ticket 0306a5563c

Artifacts Associated With Ticket 0306a5563c

  1. Ticket change [ffb54d09ec] (rid 213632) by pointsman on 2023-04-22 17:53:43:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      Run this script:
      
      package require Tcl 9
      set fd [open out.txt w+]
      puts $fd [lrepeat [expr {int(pow(2,31)) + 1}] ""]
      close $fd
      
      The tail of the created file (here the output of tail -c 20) look like:
      
       {} {} {} {} {{} {}
      
      Note here:   ^
      
      If I run the variant from above
      
      package require Tcl 9
      set fd [open out.txt w+]
      puts $fd [lrepeat [expr {int(pow(2,31)) + 1}] ""]
      close $fd
      
      the tail of the created file looks like:
      
       a a a a a a a aa a
      
      which also seems wrong.
      
    5. foundin initialized to: "Tcl 9"
    6. is_private initialized to: "0"
    7. login: "pointsman"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "4ca203a8e925aecdd9419645f936bccf18cd6ea7"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "pointsman"
    14. subsystem initialized to: "18. Commands M-Z"
    15. title initialized to: "Writing large lists to file create wrong results"
    16. type initialized to: "Bug"
  2. Ticket change [884a74c8d7] (rid 213633) by pointsman on 2023-04-22 17:54:09:

    1. comment changed to:
      Run this script:
      
      package require Tcl 9
      set fd [open out.txt w+]
      puts $fd [lrepeat [expr {int(pow(2,31)) + 1}] ""]
      close $fd
      
      The tail of the created file (here the output of tail -c 20) look like:
      
       {} {} {} {} {{} {}
      
      Note here:   ^
      
      If I run the variant from above
      
      package require Tcl 9
      set fd [open out.txt w+]
      puts $fd [lrepeat [expr {int(pow(2,31)) + 1}] a]
      close $fd
      
      the tail of the created file looks like:
      
       a a a a a a a aa a
      
      which also seems wrong.
      
    2. login: "pointsman"
    3. mimetype: "text/plain"
  3. Ticket change [c35111efcd] (rid 213646) by apnadkarni on 2023-04-23 02:35:40:

    1. icomment:
      The issue could be in string generation from a list or in the puts / channel system. The following seems to indicate the latter.
      
      ```
      % set s [testbigdata string 0x80000004]; string length $s
      2147483652
      % set fd [open x.txt w]
      file2a4826a5a68
      % puts $fd $s
      % close $fd
      % string range $s end-20 end
      123456789012345678901
      ```
      
      Tailing the file,
      
      ```
      apnadkarni@IO:/mnt/d/src/tcltk/trunk/tcl/win$ tail -c 40 x.txt
      45678901234567890123456789012345601234
      ```
      
      Notice the 6 followed by 0 at the end. That's right around the INT_MAX offset into the string.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  4. Ticket change [c4ac86310a] (rid 213647) by apnadkarni on 2023-04-23 02:36:36:

    1. icomment:
      Changed ticket title as I think it is not related to lists.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
    4. title changed to: "Writing large strings to file create wrong results"
  5. Ticket change [e1ac8520fc] (rid 213731) by pointsman on 2023-04-23 23:57:41:

    1. icomment:
      [Sorry again. While not completely wrong at the previous place it belongs to here.]
      
      The fix for[3d01d51bc4] with commit [186e4d9317] didn't really fix the problem.
      
      Look at 
      [https://core.tcl-lang.org/tcl/artifact?udc=1&ln=4262-4278&name=ce11265346dd36a3]
      
      In that loop the scr pointer will not be incrementend. Which means that after every INT_MAX bytes written it starts over from the start of the string instead of continuing. This explains the output of the examples given so far.
      
      An obvious fix is
      
      https://core.tcl-lang.org/tcl/artifact?udc=1&ln=4276&name=abf0f8ddf7519a1f
      
      with which all the so far given examples run as expected.
      
      But this raises the question what WriteChars(chanPtr, src, chunkSize) does if the chunkSize ends in the middle of a multibyte char?
      
      Some answers to that question doesn't look promissing (need a Tcl 9 tcltest to run this example script):
      
      set s [testbigdata string 0x7FFFFFFE]
      # The character to append in the next line is EM DASH, 
      # code point 0x2014 (decimal 8212, UTF-8 #xE2 #x80 #x94, 
      append s —
      set fd [open out.txt w+]
      puts $fd $s
      close $fd
      
      If I run this (on debian) I get:
      
      error writing "file6": invalid or incomplete multibyte or wide character
          while executing
      "puts $fd $s"
      
    2. login: "pointsman"
    3. mimetype: "text/x-fossil-plain"
  6. Ticket change [b6acc08d1a] (rid 214369) by pointsman on 2023-05-02 22:06:54:

    1. closedate changed to: "2460067.42146787"
    2. closer changed to: "pointsman"
    3. icomment:
      Turns out instead of breaking up the data in Tcl_WriteObj() into MAX_INT chunks it's much easier the make the called function Write() to work correctly on larger strings.
      
      Processing in chunks has a problem with chunks that ends inbetween a multi-byte character. To work around that seemd unnecessary convoluted.
      
      So I basically restored Tcl_WriteObj() to before the [3d01d51bc4] triggered changes and made Write() Tcl_Size ready.
      
      Fixed with [36eb6e392]
      
    4. login: "pointsman"
    5. mimetype: "text/x-fossil-plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"