Regex Find can cause VS Code to Freeze
See original GitHub issue- VSCode Version: 1.14.1
- OS Version: Mac OSX Sierra 10.12.5 (16F73)
Steps to Reproduce:
code --disable-extensions
- File->New File
- Paste file from here: snippets.py (it happens with other files, but this is a simple example)
- Edit->Find
"""(.*?\n?)+?"""
regex - Try to remove the last
?
from the regex. - The editor freezes at this point
- Code Helper goes to 100% CPU.
Result:
Reproduces without extensions: Yes
Issue Analytics
- State:
- Created 6 years ago
- Reactions:27
- Comments:35 (8 by maintainers)
Top Results From Across the Web
Regex search causes VS-Code to crash on macbook
I don't believe that is supported in vscode search across files. In any case, your original regex froze vscode on my Windows machine, ......
Read more >Catastrophic backtracking - The Modern JavaScript Tutorial
Catastrophic backtracking. Some regular expressions are looking simple, but can execute a veeeeeery long time, and even “hang” the ...
Read more >Bracket pair colorization 10000x faster - Visual Studio Code
To make this easier, in 2016, a user named CoenraadS developed the awesome Bracket ... This ensures that the UI does not freeze,...
Read more >Use regular expressions - Visual Studio (Windows)
Purpose Expression Example
Match any single character in a set b matches "ba", "bb", and "bc"
Escape the character following the backslash \ \^ matches...
Read more >Regular expression Denial of Service - ReDoS
An attacker can then cause a program using a Regular Expression (Regex) to ... (if needed) until a match is found (or all...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
Thanks!
Another case:
Steps:
(.*+'\n'+
)
after the third character