Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9b47b46d6c176fad04424af5e185758aa2999bf413d21eb3969a78c63bb004df
Ticket: 945d2387d7234f63c9df461e36af02b9729ce941
Tcl_ExternalToUtf hangs on valid input if character limit is specified
User & Date: apnadkarni on 2024-08-20 13:35:00
Changes

  1. 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...
    ```
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"