Steps to Reproduce:
code --disable-extensions"""(.*?\n?)+?""" regex? from the regex.Result:

Reproduces without extensions: Yes
It also happens with: 1.15.0-insider
I close it by accident. This is a real issue.
Really good catch! Unfortunately search viewlet shares the same issue.
cc @roblourens
The reason for the hang is the regex """(.*?\n?)+?""" has Catastrophic Backtracking, you can run into the same hang/100% CPU when executing this regex agains that snippet.py file in any browser.
We should have some timeout here to avoid the hang however.
@rebornix it probably only impacts the search viewlet when the file is open, right? I think Rust's regex engine is not susceptible to this. So it would be fixed by any fix to the editor.
@roblourens yes exactly as you said. It should just be a fix in the editor side.
Another case:
Steps:
t({phrase: 'mail_text_q', locale: 'ru-RU'}, mailCtx)+'\n'+
t({phrase: 'mail_text_m', locale: 'ru-RU'}, mailCtx)+'\n'+
(.*+'\n'+) after the third character(.*
^
I have another case of a regex search that hangs VS Code: /\*(.*\n?)*\*/.
* character specifically (I reproduced it many times to make sure it was this specific character hanging), so: /\*(.*\n?)*\ works, then as you type the * right after that, it hangs.This is on VS Code 1.21.1, on Windows 10, both x64.
I found an another one that hangs. (.*)\(\d*\
I attempted to turn a rather large HTML file (577KB) into a CSV containing only data from that file. I can't share that file due to privacy reasons.
(.*)\(\d*\ and possibly punch in another space after itThere's about 25% CPU activity after it hangs, but I've been waiting a couple of minutes now. A regex shouldn't ever hang the whole editor.
Does this issue occur when all extensions are disabled?: Yes

Input order:
\s19:.*. to start
Input order:
- input
\s19:.*- insert
.to start- vscode freezed
Vscod Version: 1.31.1
Os: mac 10.14.3
Curious that it's such a problem since other editors like Sublime don't have a problem with highlighting regex matches... Why is newline such an issue? Shouldn't it be just another character?
Curious that it's such a problem since other editors like Sublime don't have a problem with highlighting regex matches... Why is newline such an issue? Shouldn't it be just another character?
Actually I've tested my search in Sublime and there I have the following messages (but no crash!):
ERROR: Regex exhausted stack searching file
ERROR: Regex complexity too high searching file
I am running into this, too, for Find in a single file (not the global find/replace). I'm encountering the issue simply by using a pipe character (|) in my RegEx, when I have not yet populated characters after the pipe character. If I try enter something like
element|
(eventually intending to type element|getElement), VSCode freezes up, before I've even hit "Enter" to do the Find.
This is on VSCode version 1.39.2, on Max OSX Mojave (v10.14.6).
Version: 1.41.1 (user setup)
Commit: 26076a4de974ead31f97692a0d32f90d735645c0
Date: 2019-12-18T14:58:56.166Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18363
and still

@Fadavvi please open a new issue, I can't repro it. I'm curious whether it happens without the "whole word" toggle enabled, or in a shorter file.
@Fadavvi please open a new issue, I can't repro it. I'm curious whether it happens without the "whole word" toggle enabled, or in a shorter file.
OK. I'll open a new issue. It happen only on some special files. I can't find similarity of files!
I am running into this, too, for Find in a single file (not the global find/replace). I'm encountering the issue simply by using a pipe character (
|) in my RegEx, when I have not yet populated characters after the pipe character. If I try enter something likeelement|(eventually intending to type
element|getElement), VSCode freezes up, before I've even hit "Enter" to do the Find.This is on VSCode version 1.39.2, on Max OSX Mojave (v10.14.6).
+1 to this on VSCode 1.45.0 on Linux x64 5.6.0-1-amd64 (Debian)
Very simple regex to reproduce: (x|)
Looks to be fixed in 1.45.1 for me. @Artemis21 can you repro in 1.45.1?
I'm using VS Code 1.45.1, and I've just found another regex that will cause VS Code to freeze: "([^]+\n)+"
I've reproduced this with some minimal examples: https://gist.github.com/ndbroadbent/bb5e246b05488296576ee3dc39d40e38
(I've tested these with code --disable-extensions to disable all extensions.)
One example freezes my computer for about 1-2 seconds. The other example just has a few extra lines, but it looks like it causes a huge exponential increase in complexity and freezes VS Code forever.
It would be a really good idea to add a simple timeout so that we don't accidentally freeze the editor.
These error messages from Sublime would be even better:
ERROR: Regex exhausted stack searching file
ERROR: Regex complexity too high searching file
Thanks!
This https://twitter.com/schuay/status/1325715124930420736 looks promising for current case, but wonder if it will be applicable.
Details in Chromium bug tracker: Issue 10765: Tracking bug: Non-backtracking regexp execution
Most helpful comment
I'm using VS Code
1.45.1, and I've just found another regex that will cause VS Code to freeze:"([^]+\n)+"I've reproduced this with some minimal examples: https://gist.github.com/ndbroadbent/bb5e246b05488296576ee3dc39d40e38
(I've tested these with
code --disable-extensionsto disable all extensions.)One example freezes my computer for about 1-2 seconds. The other example just has a few extra lines, but it looks like it causes a huge exponential increase in complexity and freezes VS Code forever.
It would be a really good idea to add a simple timeout so that we don't accidentally freeze the editor.
These error messages from Sublime would be even better:
Thanks!