Stack Overflow Outage Postmortem
31–40 of 335 posts
Re: Stack Overflow Outage Postmortem
#32> It took 10 minutes to identify the cause. I'm impressed they were able to do this so quickly.
Probably went like this: 'web server crashed. so did another. what page did they crash on? ok, let's take a look at the post on that page. what in the....'
Re: Stack Overflow Outage Postmortem
#33Simple regex (as in formal language theory) are matched in O(n) time by finite automaton.
Extended regex like PCRE are more powerful, but most of the time are implemented by backtracking engines, where really bad regex pattern might go exponential, but even simple pattern as in postmortem can go O(n^2).
Do implementations optimize simple regex patterns to O(n) matching? Even I wrote x86 JIT regex compiler for fun some time ago. Compilation time was really bad, but matching was O(n).
Re: Stack Overflow Outage Postmortem
#34Not understanding why backtracking happened. Once it hit a non space, non end character, move on. Nothing before can match the regex.
The trick is that there's no guarantee, in general, that a match failing at character N is due to character N, so the regex engine backtracks.
Re: Stack Overflow Outage Postmortem
#35I don't understand something: the regex expected a space character, followed by the end of the string. If the last character wasn't a space, this could never match. Why did the engine keep backtracking, even though it's easy to figure out that it could never match the regex?
Re: Stack Overflow Outage Postmortem
#36Perfect. Awesome bug. Awesome Post Mortem. This was just fun to read. While this might have been caused by mistake - these types of bugs can be (and are) abused by hackers. https://www.owasp.org/index.php/Regular_expression_Denial_of... https://en.wikipedia.org/wiki/ReDoS The post also links to this video: https://vimeo.com/112065252
Re: Stack Overflow Outage Postmortem
#37The lesson seems to be "Always run trim() before running regex" and "validate content as much as possible before running regex".
Re: Stack Overflow Outage Postmortem
#38> So the Regex engine has to perform a “character belongs to a certain character class” check (plus some additional things) 20,000+19,999+19,998+…+3+2+1 = 199,990,000 times, and that takes a while. 199,990,000 isn't really all that many. I'm a little surprised it didn't just cause a momentary blip in performance. edit: whoops, i guess that's per page load
It's gonna hurt
Re: Stack Overflow Outage Postmortem
#39The lesson seems to be "Always run trim() before running regex" and "validate content as much as possible before running regex".
Can always fix this on the frontend with JavaScript for free if it's an actual problem.