4 ms·
How often have you encountered code that adds a timeout to regex matching?
by maleldil 1mo ago
How often have you encountered code that adds a timeout to regex matching?
- chr15m 1mo agoGood point. The number of times is zero. Probably something that should be implemented defensively at the library level. I guess most developers don't realise this can happen (I did not).
- inigyou 1mo agoNo you don't actually want a regex library that randomly fails when someone runs one of Chris Domas's pathological stall instructions on a different core.
- chr15m 1mo agoWhat do you want it to do under those conditions then? Stall pathologically?
- chr15m 1mo agoWhy do you say "randomly fails"? Do you consider a configurable timeout with an exception to be a random failure?
- inigyou 1mo agoYes. It will fail whenever something else in the system steals your CPU time. Calling code definitely isn't checking for errors either.
- simonreiff 1mo agoI actually did add a timer as a final "if all else fails" for my regex implementation rather recently, maybe 6 months ago. I don't even know of any scenario that could reach the timer because I have a robust allowlist/denylist and a ton of unit tests. But I would rather just be certain and it wasn't hard.