0

I have met an issue that, with certain regex and certain regex engine, some string to match triggered an unexpected CPU usage.

The problem was not hard to address AFTER it happened. So my question is, is there a way to prevent it? Maybe not exactly, but "most of the cases".

I am thinking some tool, that would tell me the general resource usage of the regex and critical cases.

Magicloud
  • 818
  • 1
  • 7
  • 17
  • Please show us the regex and the data. It could be a poorly written regex caused this, or maybe the input data is too large. – Tim Biegeleisen Feb 05 '19 at 06:20
  • @TimBiegeleisen Sorry, I do not have them right now. And the problem was fixed. The input data was just a URL string, so it cannot be "too large". Supposedly the regex was "poorly written", but how do we define "poorly" before it runs into trouble? – Magicloud Feb 05 '19 at 06:36
  • My car is broken down, but I don't know where it is, nor can I give you any other details. Would you be able to help me? – Tim Biegeleisen Feb 05 '19 at 06:37
  • @TimBiegeleisen I think the OP is more like asking "My car broke down, and I fixed it, but what precautions should I take in the future when driving, so that my car doesn't break down?" – Sweeper Feb 05 '19 at 06:40
  • @TimBiegeleisen That is my intention of the question. How do I prevent your car from breaking down? E.G. a function takes int, it is easy to guess the edge number, and even test with a sequence of numbers. But for regex, how to test? Or may I say, what is the edge string? – Magicloud Feb 05 '19 at 06:41
  • All you should know about is *Catastrophic Backtracking*. Please see the marked question. – revo Feb 05 '19 at 06:57
  • @revo Thanks. Glad to know that is the only thing to notice. – Magicloud Feb 05 '19 at 07:07

0 Answers0