Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Memory access violation in scripts > 2**31 bytes

Open27b3ce299702ab9a540d16a6f0678b6cd370e5aaCreated 4 years agoUpdated 2 years ago
Descriptionmarkdown2023-04-28 16:55:57

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.

Referenced by3
apnadkarni Ticket [27b3ce2997]: 4 changes [History diff]2023-04-28 16:57:03
apnadkarnimarkdown2023-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.

apnadkarni Closed ticket [27b3ce2997]. [History diff]2023-04-30 10:22:17
dgpplain2025-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.
dgpplain2025-02-26 13:54:26
Quick answer is no, that branch crashes too without protection.
dgpplain2025-02-26 13:56:25
Claiming and re-opening with some interest in examining what
might be done in 9.1
Log in (anonymous is fine) to add a comment.