Tcl Source Code

View Ticket
Login
Ticket UUID: 40f628e8e343f5e3cbef0cd41dff719ef2a11e34
Title: Tcl_ListObjReplace() callers fail to handle errors (LIST_MAX) properly
Type: Bug Created on: 2015-11-19 20:16:41
Submitter: dgp Assigned to: dkf
Subsystem: 14. List Object Severity: Severe
Priority: 5 Medium Last modified: 2026-11-14 19:04:38
Status: Closed Closed by: oehhar
Resolution: Fixed Closed on: 2026-11-14 19:04:38
Version: trunk
Description:
% set l [lrepeat 268435455 A]; concat
% set m [linsert $l end {*}$l]; concat
% llength $m
268435455

This ought to panic on an attempt to make 
a list longer than LIST_MAX.
User Comments:
dgp added on 2015-11-19 20:26:36:
Sorry.  ought to error, not panic.

dgp added on 2015-11-20 14:55:10:
Same botch in different clothing:

% set l [lrepeat 300000000 A]; concat
% set m [concat $l $l]; concat
% llength $m
300000000

dgp added on 2015-11-20 16:44:22:
Mostly fixed, [oo::*define] and [self] might
still have some extreme low probability issue here.

serhiy.storchaka added on 2026-10-14 18:44:45:

The remaining unchecked call was in [oo::define] (MagicDefinitionInvoke(), with a "TODO: overflow?" comment): if Tcl_ListObjReplace() failed, the following Tcl_EvalObjv() would read past the end of the list elements. Proposed fix in branch oo-define-list-overflow.

I did not find similar issues in [self]: other unchecked appends in TclOO build small lists (introspection results) which cannot reach LIST_MAX.


oehhar added on 2026-11-14 19:04:38:

Fix looks reasonable. No additional test failures.

Merged to:

  • main [f9265775]
  • core-9-0-branch [72ed6aee]

Bug closing.

Thanks, Harald