Skip to content
Tcl Source Code History Of Ticket 1810038fffffffff
Login

History Of Ticket 1810038fffffffff

Artifacts Associated With Ticket 1810038fffffffff

  1. Ticket change [d34a08c2bd] (rid 123267) by mmaslano on 2007-10-09 09:24:13:

    1. assignee initialized to: "pvgoran"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Occure in version: 8.0 and higher, I try it also in devel version 8.5b1 and the problem is still here.
      
      Reproducer:
      TCL version:
        regexp '($|^X)*' 'foo'
      
      The problem is in regular expressions code, which results in a non-terminating infinite loop during nondeterministic finite automata optimization. These loops remain even after the client disconnects and can be used to hog CPU and connections to the database until a full-fledged denial of service condition occurs.
      
      I try to attach patch soon, but at the moment I've no idea, where in code is the problem.
      
      
      
      
    4. foundin initialized to: "obsolete: 8.5b1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "mmaslano"
    10. subsystem initialized to: "43. Regexp"
    11. title initialized to: "DoS via infinite loop in regex NFA optimization"
    12. type initialized to: "Bug"
  2. Ticket change [fff9d27d4d] (rid 108852) by hobbs on 2007-10-10 01:19:49:

    1. is_private changed to: "1"
    2. priority changed to: "9 Immediate"
  3. Ticket change [876acea644] (rid 131692) by dgp on 2007-11-06 04:29:42:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Just to correct the report, this
      bug does not appear in Tcl 8.0.5:
      
      % info patch
      8.0.5
      % regexp ($|^X)* foo
      couldn't compile regular expression pattern: *+ operand could be empty
      
      The reported bug arrived in Tcl 8.1.0
      with the new regexp engine.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [ca14bbe7a1] (rid 122401) by dgp on 2007-11-06 23:35:21:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Things get stuck in the do {...} while ()
      loop inside the pullback() routine at
      about line 750 in regc_nfa.c .
      
      The stuck loop starts with nfa->nstates == 12
      and each iteration adds 2 to nfa->nstates,
      and sets progress to 1.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [fee3ae6000] (rid 108663) by dgp on 2007-11-07 00:42:01:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Enabling the dumpnfa(), here's the
      first few iterations:
      
      Original:
      
      pre 1, post 0, bos [2], bol [3], eos [4], eol [5]
      0@      no out arcs
      1>      ^0->4   ^1->4   [1]->4  [0]->4
      4.      $0->0   $1->0   [1]->0  [0]->0  ^1->10
              $1->4
      10.     [1]->4
      
      After first loop:
      
      pre 1, post 0, bos [2], bol [3], eos [4], eol [5]
      0@      no out arcs
      1>      ^0->4   ^1->4   [1]->4  [0]->4  ^1->10
      4.      $0->0   $1->0   [1]->0  [0]->0  $1->4
              ^1->13
      10.     [1]->4
      13.     $1->10
      
      After second loop:
      
      0@      no out arcs
      1>      ^0->4   ^1->4   [1]->4  [0]->4  ^1->10
              ^1->13
      4.      $0->0   $1->0   [1]->0  [0]->0  $1->4
              ^1->15
      10.     [1]->4
      13.     $1->10
      15.     $1->13
      
      ...and the pattern continues.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  6. Ticket change [f8007b755e] (rid 91465) by dgp on 2007-11-07 03:01:16:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Slightly simpler test that still
      demos the problem:
      
      % regexp ($|^)* {}
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [e2b331fe7f] (rid 87675) by dgp on 2007-11-09 01:05:28:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Possibly useful observations...
      
      Changing the parens from capturing to
      non-capturing stops the infinite loop
      in the simplified test...
      
      % regexp (?:$|^)* {}
      1
      
      ...but not in the original test...
      
      % regexp (?:$|^X)* {}
      <hangs>
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  8. Add attachment "1810038.patch" [8e73d95aa5] (rid 120110) by dgp on 2007-11-16 04:32:23.

  9. Ticket change [d538bb7180] (rid 123584) by dgp on 2007-11-16 04:32:24:

    1. icomment:
      
      
      File Added - 254493: 1810038.patch
      
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Attached patch (for HEAD) is a fix.
      File Added: 1810038.patch
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [a34ba63596] (rid 110025) by dgp on 2007-11-16 05:01:36:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2007-11-15T22:01:36"
    3. closer changed to: "dgp"
    4. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Fix committed to both branches.
      
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. username: "dgp"
  11. Ticket change [1ba8c204c9] (rid 123188) by dkf on 2007-12-02 03:49:57:

    1. is_private changed to: "0"