Skip to content
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

clang-tidy crashes when it encounters #embed in C code #107724

Closed
Crest opened this issue Sep 7, 2024 · 1 comment · Fixed by #107764
Closed

clang-tidy crashes when it encounters #embed in C code #107724

Crest opened this issue Sep 7, 2024 · 1 comment · Fixed by #107764
Labels
clang:static analyzer crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@Crest
Copy link

Crest commented Sep 7, 2024

I ran into the following crash trying to run clang-tidy on some code using C23 #embed to include a JSON schema file into a const char []. The shortened output from clang-tidy (the full-output is attached just in case):

LLVM ERROR: Support for EmbedExpr is not implemented.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /usr/local/llvm19/bin/clang-tidy main.c -- -I/usr/local/include -fblocks
1.	<eof> parser at end of file
2.	While analyzing stack:
	#0 Calling get_schema at line 99
	#1 Calling main
3.	/home/crest/friendly-s6/main.c:1074:3: Error evaluating statement
4.	/home/crest/friendly-s6/main.c:1074:3: Error evaluating statement

Here's the trimmed down code to the function that triggers the error (with line numbers to match up against the crash report).

  1070 static inline ucl_object_t *_Nonnull
  1071 get_schema(void)
  1072 {
  1073         const unsigned char schema_json[] = {
  1074                 #embed "schema.json"
  1075         };
@firewave firewave added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Sep 8, 2024
nicovank added a commit to nicovank/llvm-project that referenced this issue Sep 8, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 8, 2024

@llvm/issue-subscribers-clang-static-analyzer

Author: Crest (Crest)

I ran into the following crash trying to run clang-tidy on some code using C23 `#embed` to include a JSON schema file into a `const char []`. The shortened output from clang-tidy (the [full-output](https://github.com/user-attachments/files/16920084/clang-tidy19-embed-crash.txt) is attached just in case): ``` LLVM ERROR: Support for EmbedExpr is not implemented. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /usr/local/llvm19/bin/clang-tidy main.c -- -I/usr/local/include -fblocks 1. <eof> parser at end of file 2. While analyzing stack: #0 Calling get_schema at line 99 #1 Calling main 3. /home/crest/friendly-s6/main.c:1074:3: Error evaluating statement 4. /home/crest/friendly-s6/main.c:1074:3: Error evaluating statement ```

Here's the trimmed down code to the function that triggers the error (with line numbers to match up against the crash report).

  1070 static inline ucl_object_t *_Nonnull
  1071 get_schema(void)
  1072 {
  1073         const unsigned char schema_json[] = {
  1074                 #embed "schema.json"
  1075         };

steakhal pushed a commit that referenced this issue Sep 9, 2024
steakhal pushed a commit to steakhal/llvm-project that referenced this issue Sep 9, 2024
tru pushed a commit to steakhal/llvm-project that referenced this issue Sep 10, 2024
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this issue Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:static analyzer crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants