Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2023-01-06
15:43 • Closed ticket [8139aa83a4]: tclsh wrong result in string output when built with ... artifact: 84d6c2b9d5 user: jan.nijtmans
14:54 • New ticket [8139aa83a4]. artifact: b82cce880b user: SVIDevelopment

tclsh wrong result in string output when built with clang

Closed / Duplicate8139aa83a446e62b0102529546efdb4e03285603Created 4 years agoUpdated 4 years ago
Descriptionplain2023-01-06 14:54:33
We built tcl 8.6.11 with clang on Linux and noticed a problem when a string was output to either the console/stdout, a pipe, or a file. This problem does not occur when the same tclsh is compiled with gcc. 

If a long string (several thousands of characters) is present in a variable, and a new string is formed in double quotes with ten to twenty characters followed by the contents of the variable, then in the output the contents of the variable are overwritten at different locations, the first of which is at position 4096, by the first 12 characters of the combined string. The internal representation of the variable as well as the combined string are not overwritten when checked afterwards. 

Example:
==== begin example ====
$ ./tclsh8.6 
% info patchlevel
8.6.11
% puts [array get ::tcl_platform]
osVersion 5.15.0-52-generic pointerSize 8 byteOrder littleEndian threaded 1 machine x86_64 platform unix pathSeparator : os Linux engine Tcl user builder wordSize 8
% set dotString [string repeat . 5000]
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
% set x "XXXXXXXXXXXXXXXXXXXXX$dotString" 
XXXXXXXXXXXXXXXXXXXXX...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................XXXXXXXXXXXX.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
% string last X $x
20
% 
==== end example ====
$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
jan.nijtmanswiki2023-01-06 15:43:22

Dup of [24b9181478]. Already fixed in 8.6.12 and 8.6.13

Log in (anonymous is fine) to add a comment.