Artifacts Associated With Ticket 945d2387d7234f63
Ticket change [a6fe29fc1a] (rid 230403) by apnadkarni on 2024-08-20 11:08:50:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized to:
Note the test below can only be run with **tcltest** since it makes use of the testencoding command which is a direct call into Tcl_ExternalToUtf. The `encoding` command cannot reproduce this at script level because it has no means of specifying a character limit. The Tcl channel system internally does make use of the character limit but formulating an exact case is difficult because triggering the bug depends on specification of a character limit AND remaining space in the destination decode buffer (not the channel buffer), neither of which can be directly controlled at script level. I'll continue to try constructing an appropriate buffering and read sequence. In the meanwhile, here is the failure case. ``` % set utf16 [encoding convertto utf-16le A\U1F600B] A=ØÞB % testencoding Tcl_ExternalToUtf utf-16le $utf16 {start end} 0 40 nread nwrote ok 0 AðBÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ % set charlimit 2 2 % testencoding Tcl_ExternalToUtf utf-16le $utf16 {start end charlimit} 0 40 nread nwrote charlimit ...hangs... ``` Note above, the hang only occurs if the charlimit flag (`TCL_ENCODING_CHAR_LIMIT` in C) is specified - foundin initialized to: "9.0b3"
- is_private initialized to: "0"
- login: "apnadkarni"
- priority initialized to: "5 Medium"
- private_contact initialized to: "9546e9877f1a8899e25a89082561ee694e7fb402"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "apnadkarni"
- subsystem initialized to: "- New Builtin Commands"
- title initialized to:
Tcl_ExternalToUtf hangs on valid input if character limit is specified
- type initialized to: "Bug"
Ticket change [fec41d443c] (rid 230453) by jan.nijtmans on 2024-08-20 13:14:01:
- icomment:
The current TCL_ENCODING_CHAR_LIMIT implementation is horrible, anyway .....
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [9b47b46d6c] (rid 230454) by apnadkarni on 2024-08-20 13:35:00:
- icomment:
Yes, agree about `CHAR_LIMIT` implementation. However, it is (unfortunately) used by the Tcl channel system. Below is a reproduction of the bug with pure script. The buffer sizes, read sizes etc. have to be exactly as below to reproduce. Of course, other sequences are possible but not clear yet what the conditions for reproduction are or if other encodings are affected. Just create the file. ``` % set utf16ch [encoding convertto utf-16le \u4e4e] NN % set fd [open x.txt wb] file20439562060 % puts -nonewline $fd [string repeat $utf16ch 334] % puts -nonewline $fd [encoding convertto utf-16le A\U1F600B] % close $fd ``` Trigger the bug by reading exactly 336 characters (reading fewer or more works). ``` % set fd [open x.txt] file20437b89440 % fconfigure $fd -encoding utf-16le -buffersize 2000 % read $fd 336 ...hangs... ```
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [c9de470f60] (rid 231070) by apnadkarni on 2024-08-23 08:35:19:
- closedate changed to: "2460545.85786243"
- closer changed to: "apnadkarni"
- icomment: "Fixed in [df6a7e1b38]."
- login: "apnadkarni"
- mimetype: "text/x-fossil-plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"