Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 528dc7d70efda8c9cb459cb5e9c1a02e9373f10e3964079044f40efe072464fd
Ticket: a4a7f2abd376b2806073d2865f07b7d910b04574
Tcl [string match] and [glob] are exponential complexity for bad patterns, could be linear
User & Date: serhiy.storchaka on 2026-10-19 17:25:25
Changes

  1. foundin changed to: "8.6.18, 9.0.5, 9.1.0"
  2. icomment:
    Still exponential in 8.6, 9.0 and 9.1: with <tt><nowiki>string match [string repeat a* 30]b [string repeat a 30]</nowiki></tt> each failed <tt>*</tt> retries every suffix, although nothing after an exhausted string can match.
    
    Proposed fix in branch [/timeline?r=glob-match-linear|glob-match-linear]: a smaller change than the rewrite in [/timeline?r=aspect-string-match|aspect-string-match], in all four matchers (string, byte array and both Unicode ones). As in wildmat, a match that fails because the string ran out stops the outer <tt>*</tt> from retrying. The case above now takes 1 µs; 20000 random patterns give the same results as before. Test string-11.56. The edge cases of malformed patterns listed here are not changed.
    
  3. login: "serhiy.storchaka"
  4. mimetype: "text/x-fossil-wiki"