Overview
| Artifact ID: | 7d77e4c29a9a27ff66b34bc1a320227250a9b1389426d32181e5027c18edc67d |
|---|---|
| Ticket: | 41bc9a82988d930fc00145bcd02bb3ce4e169a2c
regsub -command panics with more than 9 capturing groups |
| User & Date: | serhiy.storchaka on 2026-10-11 06:54:45 |
Changes
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
<tt>regsub -command</tt> with more than 9 capturing groups can panic: <verbatim> set re {(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)} regsub -command $re abcdefghijkl {apply {args {list [llength $args] $args}}} </verbatim> In 9.0.5 this panics with "unable to alloc 643662021519030588 bytes". In 9.1.1 it happens not to crash, but the last three arguments are empty instead of <tt>j k l</tt>. Valgrind reports uninitialised reads in <tt>Tcl_RegsubObjCmd()</tt> in both. <tt>Tcl_RegsubObjCmd()</tt> always asks the regexp engine for 10 submatches, but with <tt>-command</tt> it passes all <tt>info.nsubs</tt> + 1 of them to the command, reading entries of the match array that were never set, and uses them as string positions and lengths. Asking for all submatches when <tt>-command</tt> is used fixes it; regsub.n also says that each substring matching a capturing sub-RE is appended. - foundin changed to: "9.0.5, 9.1.0"
- login: "serhiy.storchaka"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "serhiy.storchaka"
- subsystem changed to: "43. Regexp"
- title changed to:
regsub -command panics with more than 9 capturing groups
- type changed to: "Bug"