This is a followup from Bug #24358, since that thread filled up with messages about the crash in 25.1, so I'm opening a new bug for the wrong regex stack overflow check (this affects only the master branch). To reproduce the error run (re-search-forward ".*\\(\n.*\\)*" nil t) in a buffer with contents of the attached bug-24358-regex-max-specpdl.txt.