-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a crash with std::regex_match during code analysis #12285
Comments
@Lablace Thanks for reporting this. It repros on Linux but not Windows. |
@Lablace It's crashing due to a call to std::regex_match with the gcc 11.4 implementation, which seems to rely on some 256 bitset internally: It doesn't repro with clang/msvc's implementation of std::regex_match so it looks like a gcc bug. In fact, it's fixed if we use gcc 12 instead, but due to our usage of the Linux musl implementation I'm not sure if we can upgrade or not yet. |
Thanks for your detailed clarification, I had never thought this would have something to do with GCC. Let me know if I could offer more help, and feel free to close this if you like or need. |
@Lablace It's actually a known long-standing issue with the gcc regex implementation that uses the stack too much: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61601 . It's fixed after we increase the thread stack size. |
It just hit my mind that increasing the stack size would solve THIS KIND of problem (like cases when I increase the range to 512 or 1024 in the Python code, though one perhaps should not use a class to store such things) or just the specific case (range is 384)? |
@Lablace Yeah, you're right. Increasing the stack size isn't really a good fix since it'll crash again with a bigger string. I'll see if I can modify the regex or do some other string manipulation to not make it crash (i.e. limit the size of the matching it's trying to do). |
@Lablace Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.21.0 . We changed the regex used so that it wouldn't stack overflow. |
Environment
Bug Summary and Steps to Reproduce
Bug Summary:
When
clang-tidy
is enabled without tweaking check list, when diagnostic message from it is too long (in below case about 8 wrapped lines in debug output), the extension crashes.Steps to Reproduce:
Python
code below (at the end section) to generate amain.cpp
.main.cpp
Expected behavior:
I don't know if
vscode
have length limitation for diagnostic messages, if not, the extension should work well and display the message intactly, if that's the case, the extension should (at least I think it should) truncate the message and indicate user that the original message is too long to display. Anyway, I think the extension should not crash.Configuration and Logs
Other Extensions
No response
Additional context
I use this simple
Python
code to generate amain.cpp
, with whichclang-tidy
appliesclang-analyzer-optin.performance.Padding
and emitswarning: Excessive padding in 'class Sample'
, along with suggested order (which is too long).I tried replacing
384
with256
and this time the extension displayed the diagnostics normally.I also tried manually disabling the
clang-analyzer-optin.performance.Padding
check in workspace setting with"C_Cpp.codeAnalysis.clangTidy.checks.disabled": ["clang-analyzer-optin.performance.Padding"]
, and the extension worked normally too.The text was updated successfully, but these errors were encountered: