Tcl Source Code

View Ticket
Login
Ticket UUID: 176de86b3bb11df158b0245f8706cf9e543ccc19
Title: TEBCResume(): pointer overflow for INST_LREPLACE4
Type: Bug Created on: 2023-05-08 16:16:12
Submitter: chrstphrchvz Assigned to: nobody
Subsystem: 17. Commands I-L Severity: Minor
Priority: 5 Medium Last modified: 2026-11-08 06:44:29
Status: Closed Closed by: chrstphrchvz
Resolution: Duplicate Closed on: 2026-11-08 06:44:29
Version: core-9-0-branch
Description:

As of [7a2fc29ce038], numNewElems is declared as size_t, which can lead to pointer overflow in OBJ_AT_DEPTH(numNewElems - 1). Example -fsanitize=pointer-overflow error during autoMkindex-3.4:

generic/tclExecute.c:5109:9: runtime error: subtraction of unsigned offset from 0x611000099078 overflowed to 0x611000099080

Declaring numToDelete as size_t seems fine, though.

User Comments:
chrstphrchvz added on 2023-09-15 13:28:28:

As of [ba731752d345] I wonder if this issue also affects 8.7 (particularly on 32-bit); so far I have not observed that it does. However fix for this issue may still be applicable to both 8.7 and 9.0.


griffin added on 2023-09-16 17:25:35:
Fixed by broader updates to the uses of size_t everywhere.

chrstphrchvz added on 2023-09-16 22:10:27:

Can you please elaborate how this was fixed? I still observe this on trunk, since TCL_HASH_TYPE is size_t.


griffin added on 2023-09-17 16:22:19:
I cannot reproduce the error.  My first attempt produced no error. After review I realized I didn't run the build & test correctly.  It this point I cannot get tcl to build correctly with sanitize at all, let alone run.
Re-open the bug for someone else to pursue.

chrstphrchvz added on 2025-09-19 21:59:01:

This error is still present (rephrased slightly):

generic/tclExecute.c:5203:21: runtime error: addition of unsigned offset to 0x6110000748c8 overflowed to 0x6110000748b8
and:
generic/tclExecute.c:5212:21: runtime error: addition of unsigned offset to 0x6110000ada88 overflowed to 0x6110000ada80

I no longer see this error during autoMkindex tests, but there are several other tests which do trigger it; one affected command is linsert {} 0 a b.


chrstphrchvz added on 2026-11-08 06:44:29:

Closing as duplicate in favor of [94c6511e].