llvm / llvm/llvm-project

Crash while parsing function body in compound statement ('{}')

Open
#178,301 3 comments 0 reactions 0 assignees View on GitHub
clangd crash obsolete
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hi, I am currently working on a project that depends on [Corrade](https://github.com/mosra/corrade) and while using the [clangd extension](https://open-vsx.org/extension/llvm-vs-code-extensions/vscode-clangd) in [VSCodium](https://vscodium.com) the server crashes always in (at least) [one file](https://github.com/mosra/corrade/blob/master/src/Corrade/PluginManager/PluginMetadata.cpp#L38).

I believe this may be a bug and as suggested by the output, I am posting it here. Unfortunately I do not have the knowledge to understand what is going on.

Could anyone please confirm whether this is really a bug and/or if there is any way to work around or solve the issue?

Version: 21.1.8.

### (Verbose) stacktrace

```
Stack dump:
0. /home/javi/workspace/magnum/corrade/src/Corrade/PluginManager/PluginMetadata.cpp:39:69: current parser token ';'
1. /home/javi/workspace/magnum/corrade/src/Corrade/PluginManager/PluginMetadata.cpp:32:1: parsing namespace 'Corrade'
2. /home/javi/workspace/magnum/corrade/src/Corrade/PluginManager/PluginMetadata.cpp:32:21: parsing namespace 'Corrade::PluginManager'
3. /home/javi/workspace/magnum/corrade/src/Corrade/PluginManager/PluginMetadata.cpp:38:60: parsing function body 'Corrade::PluginManager::PluginMetadata::depends'
4. /home/javi/workspace/magnum/corrade/src/Corrade/PluginManager/PluginMetadata.cpp:38:60: in compound statement ('{}')
V[22:28:16.560] indexed preamble AST for /home/javi/workspace/magnum/corrade/src/Corrade/PluginManager/PluginMetadata.cpp version 71:
symbol slab: 4563 symbols, 1488095 bytes
ref slab: 0 symbols, 0 refs, 128 bytes
relations slab: 209 relations, 4376 bytes
V[22:28:16.580] Build dynamic index for header symbols with estimated memory usage of 3620163 bytes
[Error - 10:28:18 PM] Server process exited with signal SIGSEGV.
[Error - 10:28:18 PM] The Clang Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
```

### Related findings

Removing a few of the offending returns (i.e., those that look like `return static_cast(this)->depends;`), the server does not crash anymore.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.