Tcl Source Code

View Ticket
Login
Ticket UUID: 27b3ce299702ab9a540d16a6f0678b6cd370e5aa
Title: Memory access violation in scripts > 2**31 bytes
Type: Bug Created on: 2023-04-28 16:55:57
Submitter: apnadkarni Assigned to: dgp
Subsystem: 47. Bytecode Compiler Severity: Minor
Priority: 5 Medium Last modified: 2025-02-26 13:56:25
Status: Open Closed by: nobody
Resolution: None Closed on: 2025-02-26 13:54:26
Version: 9.1
Description:

Having a script longer than INT_MAX results in memory access violations even on 64-bit builds. Example is below (invalid set command is intentional)

try [string cat [string repeat " " 0x80000000] "set a b c"]

This is just one example but between the byte code compiler and TIP 280 source code -> source line number tracking there are many occasions for overflowing length limits. Fixing these is non trivial and risky so for the moment the plan is to disallow scripts or byte code sequences longer than INT_MAX.

Marking as minor since not likely to have a such a long script. Scripts in safe interps are still a concern however so protection is still desirable.

User Comments:
apnadkarni added on 2023-04-30 10:22:05:

Fixed in [20ed83cf25]. Generates a Tcl exception now instead of panics or crashes. Allowing for longer scripts is a longer term exercise, 9.1 or may be even later.


dgp added on 2025-02-26 13:49:36:
Just taking notice of this.  The limit doesn't merge to dgp-refactor,
and not yet clear if the revisions there are a means of eliminating it.

dgp added on 2025-02-26 13:54:26:
Quick answer is no, that branch crashes too without protection.

dgp added on 2025-02-26 13:56:25:
Claiming and re-opening with some interest in examining what
might be done in 9.1