-
Notifications
You must be signed in to change notification settings - Fork 59
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
Assertions triggered with unclosed parentheses, brackets, or braces with _GLIBCXX_ASSERTIONS #1559
Comments
@ckandeler perhaps you can help the bug reporter obtain logs? |
Start Qt Creator with the following environment variable set: |
Thanks, I have updated the description to include the clangd output, which has the assertion message and stack trace. It doesn't seem to have symbols for clangd itself, though it does have them for the libclang-cpp functions that actually trigger the assert. (not sure if this means it's a bug in libclang-cpp or if clangd is passing invalid parameters that lead to the assert) |
I made a local build of clangd with debug symbols based on the Arch package config and added a full stack trace to the description. |
The stack trace shows the crash occurs during the I can reproduce it with a debug build of clangd by selecting the entire file contents of one your testcases and running the "clangd: Show AST" command in VSCode. The out-of-bounds operator[] access is the one on this line, or in the case of the To clarify, when you experience this crash are you explicitly triggering a command to show the AST? Or is Qt Creator doing this automatically when a file is opened / during normal editing? |
Qt Creator requests the AST to help with certain functionality, most notably semantic highlighting (with clangd < 17). If this crash happens a lot, it's probably worth trying a snapshot from the main branch as a workaround. |
@HighCommander4 as @ckandeler indicated this happens during normal editing. The end result is that the clangd will crash in the background when typing whenever one of these situations is hit and semantic highlighting and code completion will cease to work until it's relaunched and the file no longer triggers the assert. No user action is needed apart from typing, and I typically see dozens of crashes a day as a result. @ckandeler as a temporary workaround I performed a local rebuild of the Arch |
@HighCommander4 since the location and cause of the asserts seem to be known, is there a solution you have in mind? While the hard crash is limited to distros that choose to enable the asserts, this points to potential out of bounds access and undefined behavior even when they aren't. |
I agree that this bug is concerning due to the UB potential, and that there is enough information in the bug report to debug the issue. I have not had the time to debug it myself so far. cc'ing a few folks who were involved in writing the |
It really is quite a big inconvenience, I get those crashes a few times a day on arch linux (QtCreator and clang 16.0.6-1). It seems that |
…in TokenBuffer::spelledForExpanded() Such ranges can legitimately arise in the case of invalid code, such as a declaration missing an ending brace. Fixes clangd/clangd#1559
…in TokenBuffer::spelledForExpanded() (#78092) Such ranges can legitimately arise in the case of invalid code, such as a declaration missing an ending brace. Fixes clangd/clangd#1559
Fixed for clangd 18. |
…in TokenBuffer::spelledForExpanded() (llvm#78092) Such ranges can legitimately arise in the case of invalid code, such as a declaration missing an ending brace. Fixes clangd/clangd#1559
When clang and clangd are built with _GLIBCXX_ASSERTIONS enabled (which is in the default
CXXFLAGS
some Linux distributions like Arch, Fedora, and RedHat), clangd will trigger assertions and crash for unclosed parentheses, brackets, or braces. For example, the following will assert and crash:Logs
This is a backtrace from a crash after locally re-building clangd with debug symbols:
System information
Output of
clangd --version
:clangd version 15.0.7
Features: linux
Platform: x86_64-pc-linux-gnu
Editor/LSP plugin:
Qt Creator 9.0.2
Operating system:
Arch Linux
The text was updated successfully, but these errors were encountered: