Skip to content

[clangd] crash in InlayHints.cpp on trivial FunctionProtoTypeLoc #142608

@npc1054657282

Description

@npc1054657282

The usage.c in the git project will result in this.

This is a minimal reproduce:

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>

#define NORETURN __attribute__((__noreturn__))
#define NORETURN_PTR __attribute__((__noreturn__))
typedef void (*report_fn)(const char *, va_list params);

static void NORETURN die_builtin(const char *err, va_list params)
{
	exit(128);
}

static NORETURN_PTR report_fn die_routine = die_builtin;

void NORETURN die(const char *err, ...)
{
	va_list params;

	va_start(params, err);
	die_routine(err, params);
	va_end(params);
}

The code itself is valid. But the clangd crash:

I[22:05:07.654] clangd version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
I[22:05:07.654] Features: linux+grpc
I[22:05:07.654] PID: 734406
I[22:05:07.654] Working directory: /home/npc1054657282/my_projects/clangd-crash-minimal
I[22:05:07.654] argv[0]: /home/npc1054657282/.vscode-server/data/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/19.1.2/clangd_19.1.2/bin/clangd
I[22:05:07.654] argv[1]: --compile-commands-dir=.vscode
E[22:05:07.654] Path specified by --compile-commands-dir does not exist. The argument will be ignored.
I[22:05:07.654] Starting LSP over stdin/stdout
I[22:05:07.655] <-- initialize(0)
I[22:05:07.657] --> reply:initialize(0) 1 ms
I[22:05:07.683] <-- initialized
I[22:05:07.686] <-- textDocument/didOpen
I[22:05:07.688] Failed to find compilation database for /home/npc1054657282/my_projects/clangd-crash-minimal/usage.c
I[22:05:07.688] ASTWorker building file /home/npc1054657282/my_projects/clangd-crash-minimal/usage.c version 464 with command clangd fallback
[/home/npc1054657282/my_projects/clangd-crash-minimal]
/usr/bin/clang -resource-dir=/home/npc1054657282/.vscode-server/data/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/19.1.2/clangd_19.1.2/lib/clang/19 -- /home/npc1054657282/my_projects/clangd-crash-minimal/usage.c
I[22:05:07.691] --> textDocument/clangd.fileStatus
I[22:05:07.728] Built preamble of size 398024 for file /home/npc1054657282/my_projects/clangd-crash-minimal/usage.c version 464 in 0.04 seconds
I[22:05:07.730] Indexing c17 standard library in the context of /home/npc1054657282/my_projects/clangd-crash-minimal/usage.c
I[22:05:07.730] --> textDocument/clangd.fileStatus
I[22:05:07.730] --> textDocument/clangd.fileStatus
I[22:05:07.730] --> workspace/semanticTokens/refresh(0)
I[22:05:07.740] <-- reply(0)
I[22:05:07.752] --> textDocument/publishDiagnostics
I[22:05:07.752] --> textDocument/inactiveRegions
I[22:05:07.752] --> textDocument/clangd.fileStatus
I[22:05:07.859] <-- textDocument/documentSymbol(1)
I[22:05:07.859] <-- textDocument/documentLink(2)
I[22:05:07.859] <-- textDocument/inlayHint(3)
I[22:05:07.859] <-- textDocument/semanticTokens/full(4)
I[22:05:07.859] <-- textDocument/codeAction(5)
I[22:05:07.860] --> reply:textDocument/documentSymbol(1) 1 ms
I[22:05:07.860] --> reply:textDocument/documentLink(2) 1 ms
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clangd          0x000000000055715b
1  clangd          0x0000000000554fbe
2  clangd          0x0000000000557af6
3  libpthread.so.0 0x00007f15ee7ed1d0
4  clangd          0x00000000016e51ba
5  clangd          0x00000000016e2d2c
6  clangd          0x00000000016dcf39
7  clangd          0x00000000016d1bef
8  clangd          0x00000000016e80aa
9  clangd          0x00000000016cd610
10 clangd          0x00000000016cf545
11 clangd          0x00000000016cad1e
12 clangd          0x00000000015f573f
13 clangd          0x000000000179856c
14 clangd          0x000000000178fa0b
15 clangd          0x000000000178e460
16 clangd          0x000000000190f7c1
17 libpthread.so.0 0x00007f15ee7e23fb
18 libc.so.6       0x00007f15ee4e2e83 clone + 67
Signalled during AST worker action: InlayHints
  Filename: usage.c
  Directory: /home/npc1054657282/my_projects/clangd-crash-minimal
  Command Line: /usr/bin/clang -resource-dir=/home/npc1054657282/.vscode-server/data/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/19.1.2/clangd_19.1.2/lib/clang/19 -- /home/npc1054657282/my_projects/clangd-crash-minimal/usage.c
  Version: 464
[Error - 10:05:08 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.
[Error - 10:05:08 PM] Request textDocument/inlayHint failed.
[object Object]
[Error - 10:05:08 PM] Request textDocument/semanticTokens/full failed.
[object Object]
[Error - 10:05:08 PM] Request textDocument/codeAction failed.
[object Object]

Metadata

Metadata

Labels

clangdcrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions