-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.help wanted
Milestone
Description
As discussed on https://groups.google.com/forum/#!topic/golang-nuts/8M-qVbRKIWA
Playground link to illustrate: https://play.golang.org/p/82UBmyfyqV-
Regular expressions with large numbers of empty alternations are taking a long time to compile. The time required is roughly quadratic in the length of the regex.
The quadratic algorithm is building the patchlist by repeatedly appending to it. Since it is a linked list with no tail pointer, appending to it is O(n). The append
method is found in regexp/syntax/compile.go, at line 42.
I don't know that this is exactly a bug, but it is surprising that although executing a regex is linear-time, compiling one isn't. It probably doesn't affect any useful regex, but it might be a DOS vector.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.help wanted