|
2024-08-31
| ||
| 07:38 | Merge [df6a7e1b38bfae63]: Fix [33f9b4de51], [945d2387d7], [f2e924e881] - encoding character limit bu... check-in: 6711cc9484 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2024-08-23
| ||
| 08:35 | • Closed ticket [945d2387d7]: Tcl_ExternalToUtf hangs on valid input if character ... artifact: c9de470f60 user: apnadkarni | |
| 08:32 | Fix [33f9b4de51], [945d2387d7], [f2e924e881] - encoding character limit bugs check-in: df6a7e1b38 user: apnadkarni tags: trunk, main | |
|
2024-08-22
| ||
| 18:12 | Proposed fixes for [945d2387d7], [f2e924e881], [33f9b4de51] check-in: c19b624fa9 user: apnadkarni tags: bug-945d2387d7 | |
|
2024-08-21
| ||
| 12:06 | Start on bug [945d2387d7] check-in: 8a8db8eace user: apnadkarni tags: bug-945d2387d7 | |
|
2024-08-20
| ||
| 13:35 | • Ticket [945d2387d7] Tcl_ExternalToUtf hangs on valid input if character limit is... artifact: 9b47b46d6c user: apnadkarni | |
| 13:14 | • Ticket [945d2387d7]: 3 changes artifact: fec41d443c user: jan.nijtmans | |
| 11:08 | • New ticket [945d2387d7]. artifact: a6fe29fc1a user: apnadkarni | |
Tcl_ExternalToUtf hangs on valid input if character limit is specified
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
6711cc9484Merge [df6a7e1b38bfae63]: Fix [33f9b4de51], [945d2387d7], [f2e924e881] - encoding character limit bugs. check-in2024-08-31 07:38:40df6a7e1b38Fix [33f9b4de51], [945d2387d7], [f2e924e881] - encoding character limit bugs check-in2024-08-23 08:32:29c19b624fa9Proposed fixes for [945d2387d7], [f2e924e881], [33f9b4de51] check-in2024-08-22 18:12:158a8db8eaceStart on bug [945d2387d7] check-in2024-08-21 12:06:34
The current TCL_ENCODING_CHAR_LIMIT implementation is horrible, anyway .....
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...
Fixed in [df6a7e1b38].