llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Clang] Crash Behavior change from access violation reading source operand in Clang 20.1.2 to Bad Instruction execution in Clang 21.1.8

Open apbenson00 opened this issue 9 months ago • 3 comments

Bug

A crashing input that CASR marked as SourceAv (access violation on a source operand) in Clang 20.1.2 now triggers a Bad Instruction crash in Clang 21.1.8. The crash is reproducible with the same test file, but the crash type and severity changed. The bug was found using AFL++ and categorized using CASR.

Code

crash.c

Command

clang crash.c

Expected Output

Syntax error and graceful exit

Actual Output

Clang 20.1.2

./min_cluster_32.c:1:1: error: unknown type name 'inrint'; did you mean 'inline'?
    1 | inrint // R%clang_cc1 -<F3>syntax-only %s 2> <U+0018>
      | ^~~~~~
      | inline
./min_cluster_32.c:2:1: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      | ^
./min_cluster_32.c:1:1: error: 'inline' can only appear on functions
    1 | inrint // R%clang_cc1 -<F3>syntax-only %s 2> <U+0018>
      | ^
./min_cluster_32.c:2:6: error: unknown type name 'mgm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |      ^
./min_cluster_32.c:2:13: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |             ^
./min_cluster_32.c:2:20: error: expected ';' after top level declarator
    2 | m  x;mgm  x;m  rict-whitespace %s
      |                    ^
      |                    ;
./min_cluster_32.c:15:28: error: source file is not valid UTF-8
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                            ^
./min_cluster_32.c:15:34: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
      |                                int
./min_cluster_32.c:15:34: error: expected ')'
./min_cluster_32.c:15:12: note: to match this '('
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |            ^
./min_cluster_32.c:15:85: error: expected ')'
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                                                                        ^
      |                                                                                        )
./min_cluster_32.c:15:6: warning: GCC requires a function with the '__format__' attribute to be variadic [-Wgcc-compat]
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |      ^
./min_cluster_32.c:15:6: warning: incompatible redeclaration of library function 'printf' [-Wincompatible-library-redeclaration]
./min_cluster_32.c:15:6: note: 'printf' is a builtin with type 'int (const char *, ...)'
./min_cluster_32.c:12:10: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *****' [-Wint-conversion]
   12 |          x);
      |          ^
./min_cluster_32.c:15:34: note: passing argument to parameter here
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
./min_cluster_32.c:11:13: warning: invalid conversion specifier 'N' [-Wformat-invalid-specifier]
   11 |   printf("%+NEXT: {{^}}  ine",
      |           ~~^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /usr/lib/llvm-20/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name min_cluster_32.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/user/test -fcoverage-compilation-dir=/home/user/test -resource-dir /usr/lib/llvm-20/lib/clang/20 -internal-isystem /usr/lib/llvm-20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/min_cluster_32-ec0522.o -x c ./min_cluster_32.c
1.	./min_cluster_32.c:12:11: current parser token ')'
2.	./min_cluster_32.c:10:15: parsing function body 'f'
3.	./min_cluster_32.c:10:15: in compound statement ('{}')
fatal error: error in backend: IO failure on output stream: No space left on device

Clang 21.1.8 Error Message:

./crash.c:1:1: error: unknown type name 'inrint'; did you mean 'inline'?
    1 | inrint // R%clang_cc1 -<F3>syntax-only %s 2> <U+0018>
      | ^~~~~~
      | inline
./crash.c:2:1: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      | ^
./crash.c:1:1: error: 'inline' can only appear on functions
    1 | inrint // R%clang_cc1 -<F3>syntax-only %s 2> <U+0018>
      | ^
./crash.c:2:6: error: unknown type name 'mgm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |      ^
./crash.c:2:13: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |             ^
./crash.c:2:20: error: expected ';' after top level declarator
    2 | m  x;mgm  x;m  rict-whitespace %s
      |                    ^
      |                    ;
./crash.c:15:28: error: source file is not valid UTF-8
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                            ^
./crash.c:15:34: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
      |                                int
./crash.c:15:34: error: expected ')'
./crash.c:15:12: note: to match this '('
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |            ^
./crash.c:15:85: error: expected ')'
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                                                                        ^
      |                                                                                        )
./crash.c:15:6: warning: GCC requires a function with the '__format__' attribute to be variadic [-Wgcc-compat]
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |      ^
./crash.c:15:6: warning: incompatible redeclaration of library function 'printf' [-Wincompatible-library-redeclaration]
./crash.c:15:6: note: 'printf' is a builtin with type 'int (const char *, ...)'
./crash.c:12:10: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *****' [-Wint-conversion]
   12 |          x);
      |          ^
./crash.c:15:34: note: passing argument to parameter here
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
./crash.c:11:13: warning: invalid conversion specifier 'N' [-Wformat-invalid-specifier]
   11 |   printf("%+NEXT: {{^}}  ine",
      |           ~~^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/user/afl_versions/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name crash.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/user/test -fcoverage-compilation-dir=/home/user/test -resource-dir /home/user/lib/clang/21 -internal-isystem /home/user/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=204 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/crash-ffb128.o -x c ./crash.c
1.	./crash.c:12:11: current parser token ')'
2.	./crash.c:10:15: parsing function body 'f'
3.	./crash.c:10:15: in compound statement ('{}')
fatal error: error in backend: IO failure on output stream: No space left on device

Environment

  • OS: Ubuntu 25
  • Arch: x86_64
  • RAM 64GB

CASR Output

Clang 21.1.8:

  "ProcFiles": [],
  "NetworkConnections": [],
  "CrashSeverity": {
    "Type": "PROBABLY_EXPLOITABLE",
    "ShortDescription": "BadInstruction",
    "Description": "Bad instruction",
    "Explanation": "The target tried to execute a malformed or privileged instruction. This may indicate that the control flow is tainted."
  },

Clang 20.1.2

 "ProcFiles": [],
  "NetworkConnections": [],
  "CrashSeverity": {
    "Type": "NOT_EXPLOITABLE",
    "ShortDescription": "SourceAv",
    "Description": "Access violation on source operand",
    "Explanation": "The target crashed on an access violation at an address matching the source operand of the current instruction. This likely indicates a read access violation."
  },

apbenson00 avatar Feb 16 '26 21:02 apbenson00

This bug was found from fuzzing. The output from Clang 23 is as follows:

  • I could not reproduce this bug on CompilerExplorer in any tested version.

Clang Report

# Crash reproducer for clang version 23.0.0git (https://github.com/llvm/llvm-project.git 7be392e0ea13f96aae8e7082a3c0206e09cd2f03)
# Driver args: "/home/user/Data/crash.c"
# Original command:  "/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin/clang-23" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-dumpdir" "a-" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "crash.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin" "-fcoverage-compilation-dir=/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin" "-resource-dir" "/home/user/LLVM_Testing/current_version_clang/llvm-project/build/lib/clang/23" "-internal-isystem" "/home/user/LLVM_Testing/current_version_clang/llvm-project/build/lib/clang/23/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fmessage-length=204" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-faddrsig" "-fdwarf2-cfi-asm" "-o" "/tmp/crash-ca60fb.o" "-x" "c" "/home/user/Data/crash.c"
 "/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin/clang-23" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-dumpdir" "a-" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "crash.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin" "-fcoverage-compilation-dir=/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin" "-ferror-limit" "19" "-fmessage-length=204" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-faddrsig" "-fdwarf2-cfi-asm" "-x" "c" "crash-66abb6.c"

Stack Dump from Assertion Build:

clang-23: /home/user/LLVM_Testing/current_version_clang/llvm-project/llvm/include/llvm/ADT/SmallVector.h:297: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](size_type) [with T = long unsigned int; <template-parameter-1-2> = void; reference = long unsigned int&; size_type = long unsigned int]: Assertion `idx < size()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin/clang-23 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name crash.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin -fcoverage-compilation-dir=/home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin -resource-dir /home/user/LLVM_Testing/current_version_clang/llvm-project/build/lib/clang/23 -internal-isystem /home/user/LLVM_Testing/current_version_clang/llvm-project/build/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=204 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -fdwarf2-cfi-asm -o /tmp/crash-ca60fb.o -x c /home/user/Data/crash.c
1.	/home/user/Data/crash.c:12:11: current parser token ')'
2.	/home/user/Data/crash.c:10:15: parsing function body 'f'
3.	/home/user/Data/crash.c:10:15: in compound statement ('{}')
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  clang-23  0x00005d5101e35d90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 64
1  clang-23  0x00005d5101e32834 llvm::sys::RunSignalHandlers() + 52
2  clang-23  0x00005d5101e329e9
3  libc.so.6 0x00007e9aaac458d0
4  libc.so.6 0x00007e9aaaca49bc pthread_kill + 284
5  libc.so.6 0x00007e9aaac4579e gsignal + 30
6  libc.so.6 0x00007e9aaac288cd abort + 44
7  libc.so.6 0x00007e9aaac28830 __assert_perror_fail + 0
8  clang-23  0x00005d51005a20ce
9  clang-23  0x00005d51005a90c8
10 clang-23  0x00005d51042d17d7
11 clang-23  0x00005d51054fe4a6
12 clang-23  0x00005d51054fed4d clang::analyze_format_string::ParsePrintfString(clang::analyze_format_string::FormatStringHandler&, char const*, char const*, clang::LangOptions const&, clang::TargetInfo const&, bool) + 157
13 clang-23  0x00005d51042ed312
14 clang-23  0x00005d51042ed9c6 clang::Sema::CheckFormatArguments(llvm::ArrayRef<clang::Expr const*>, clang::Sema::FormatArgumentPassingKind, clang::StringLiteral*, unsigned int, unsigned int, clang::FormatStringType, clang::VariadicCallType, clang::SourceLocation, clang::SourceRange, llvm::SmallBitVector&) + 310
15 clang-23  0x00005d51042eee5e clang::Sema::CheckFormatArguments(clang::FormatAttr const*, llvm::ArrayRef<clang::Expr const*>, bool, clang::VariadicCallType, clang::SourceLocation, clang::SourceRange, llvm::SmallBitVector&) + 142
16 clang-23  0x00005d51042ef70f clang::Sema::checkCall(clang::NamedDecl*, clang::FunctionProtoType const*, clang::Expr const*, llvm::ArrayRef<clang::Expr const*>, bool, clang::SourceLocation, clang::SourceRange, clang::VariadicCallType) + 2127
17 clang-23  0x00005d51042f18df clang::Sema::CheckFunctionCall(clang::FunctionDecl*, clang::CallExpr*, clang::FunctionProtoType const*) + 271
18 clang-23  0x00005d5104597a67 clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) + 5319
19 clang-23  0x00005d5104567eb3 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) + 83
20 clang-23  0x00005d5104137acd clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) + 653
21 clang-23  0x00005d5104131982 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) + 706
22 clang-23  0x00005d5104134c87 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) + 55
23 clang-23  0x00005d5104134d28 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) + 56
24 clang-23  0x00005d51041374fd clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) + 13
25 clang-23  0x00005d51041b7afd clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) + 77
26 clang-23  0x00005d51041b06a4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) + 4468
27 clang-23  0x00005d51041b0ef3 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) + 419
28 clang-23  0x00005d51041b22bf clang::Parser::ParseCompoundStatementBody(bool) + 1631
29 clang-23  0x00005d51041b2c6f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 207
30 clang-23  0x00005d51040c704e clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 3310
31 clang-23  0x00005d5104103790 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 6640
32 clang-23  0x00005d51040c1240 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 976
33 clang-23  0x00005d51040c1a5f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 959
34 clang-23  0x00005d51040c8511 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 609
35 clang-23  0x00005d51040c9fed clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 477
36 clang-23  0x00005d51040ad6fa clang::ParseAST(clang::Sema&, bool, bool) + 586
37 clang-23  0x00005d5102961c65 clang::FrontendAction::Execute() + 53
38 clang-23  0x00005d51028ef04e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 654
39 clang-23  0x00005d5102a39335 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 629
40 clang-23  0x00005d51009fe619 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 3705
41 clang-23  0x00005d51009f75e3
42 clang-23  0x00005d51009f97e8 clang_main(int, char**, llvm::ToolContext const&) + 5672
43 clang-23  0x00005d51008f2ed8 main + 104
44 libc.so.6 0x00007e9aaac2a578
45 libc.so.6 0x00007e9aaac2a63b __libc_start_main + 139
46 clang-23  0x00005d51009f5a95 _start + 37
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 23.0.0git (https://github.com/llvm/llvm-project.git 7be392e0ea13f96aae8e7082a3c0206e09cd2f03)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/user/LLVM_Testing/current_version_clang/llvm-project/build/bin
Build config: +assertions

apbenson00 avatar Feb 17 '26 15:02 apbenson00

@llvm/issue-subscribers-clang-frontend

Author: Andy Benson (apbenson00)

### Bug A crashing input that CASR marked as SourceAv (access violation on a source operand) in Clang 20.1.2 now triggers a Bad Instruction crash in Clang 21.1.8. The crash is reproducible with the same test file, but the crash type and severity changed. The bug was found using AFL++ and categorized using CASR.

Code

crash.c

Command

clang crash.c

Expected Output

Syntax error and graceful exit

Actual Output

Clang 20.1.2

./min_cluster_32.c:1:1: error: unknown type name 'inrint'; did you mean 'inline'?
    1 | inrint // R%clang_cc1 -&lt;F3&gt;syntax-only %s 2&gt; &lt;U+0018&gt;
      | ^~~~~~
      | inline
./min_cluster_32.c:2:1: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      | ^
./min_cluster_32.c:1:1: error: 'inline' can only appear on functions
    1 | inrint // R%clang_cc1 -&lt;F3&gt;syntax-only %s 2&gt; &lt;U+0018&gt;
      | ^
./min_cluster_32.c:2:6: error: unknown type name 'mgm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |      ^
./min_cluster_32.c:2:13: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |             ^
./min_cluster_32.c:2:20: error: expected ';' after top level declarator
    2 | m  x;mgm  x;m  rict-whitespace %s
      |                    ^
      |                    ;
./min_cluster_32.c:15:28: error: source file is not valid UTF-8
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                            ^
./min_cluster_32.c:15:34: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
      |                                int
./min_cluster_32.c:15:34: error: expected ')'
./min_cluster_32.c:15:12: note: to match this '('
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |            ^
./min_cluster_32.c:15:85: error: expected ')'
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                                                                        ^
      |                                                                                        )
./min_cluster_32.c:15:6: warning: GCC requires a function with the '__format__' attribute to be variadic [-Wgcc-compat]
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |      ^
./min_cluster_32.c:15:6: warning: incompatible redeclaration of library function 'printf' [-Wincompatible-library-redeclaration]
./min_cluster_32.c:15:6: note: 'printf' is a builtin with type 'int (const char *, ...)'
./min_cluster_32.c:12:10: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *****' [-Wint-conversion]
   12 |          x);
      |          ^
./min_cluster_32.c:15:34: note: passing argument to parameter here
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
./min_cluster_32.c:11:13: warning: invalid conversion specifier 'N' [-Wformat-invalid-specifier]
   11 |   printf("%+NEXT: {{^}}  ine",
      |           ~~^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /usr/lib/llvm-20/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name min_cluster_32.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/user/test -fcoverage-compilation-dir=/home/user/test -resource-dir /usr/lib/llvm-20/lib/clang/20 -internal-isystem /usr/lib/llvm-20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/min_cluster_32-ec0522.o -x c ./min_cluster_32.c
1.	./min_cluster_32.c:12:11: current parser token ')'
2.	./min_cluster_32.c:10:15: parsing function body 'f'
3.	./min_cluster_32.c:10:15: in compound statement ('{}')
fatal error: error in backend: IO failure on output stream: No space left on device

Clang 21.1.8 Error Message:

./crash.c:1:1: error: unknown type name 'inrint'; did you mean 'inline'?
    1 | inrint // R%clang_cc1 -&lt;F3&gt;syntax-only %s 2&gt; &lt;U+0018&gt;
      | ^~~~~~
      | inline
./crash.c:2:1: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      | ^
./crash.c:1:1: error: 'inline' can only appear on functions
    1 | inrint // R%clang_cc1 -&lt;F3&gt;syntax-only %s 2&gt; &lt;U+0018&gt;
      | ^
./crash.c:2:6: error: unknown type name 'mgm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |      ^
./crash.c:2:13: error: unknown type name 'm'
    2 | m  x;mgm  x;m  rict-whitespace %s
      |             ^
./crash.c:2:20: error: expected ';' after top level declarator
    2 | m  x;mgm  x;m  rict-whitespace %s
      |                    ^
      |                    ;
./crash.c:15:28: error: source file is not valid UTF-8
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                            ^
./crash.c:15:34: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
      |                                int
./crash.c:15:34: error: expected ')'
./crash.c:15:12: note: to match this '('
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |            ^
./crash.c:15:85: error: expected ')'
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                                                                        ^
      |                                                                                        )
./crash.c:15:6: warning: GCC requires a function with the '__format__' attribute to be variadic [-Wgcc-compat]
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |      ^
./crash.c:15:6: warning: incompatible redeclaration of library function 'printf' [-Wincompatible-library-redeclaration]
./crash.c:15:6: note: 'printf' is a builtin with type 'int (const char *, ...)'
./crash.c:12:10: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *****' [-Wint-conversion]
   12 |          x);
      |          ^
./crash.c:15:34: note: passing argument to parameter here
   15 | void printf(const char *a, &lt;F2&gt;*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
./crash.c:11:13: warning: invalid conversion specifier 'N' [-Wformat-invalid-specifier]
   11 |   printf("%+NEXT: {{^}}  ine",
      |           ~~^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/user/afl_versions/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name crash.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/user/test -fcoverage-compilation-dir=/home/user/test -resource-dir /home/user/lib/clang/21 -internal-isystem /home/user/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=204 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/crash-ffb128.o -x c ./crash.c
1.	./crash.c:12:11: current parser token ')'
2.	./crash.c:10:15: parsing function body 'f'
3.	./crash.c:10:15: in compound statement ('{}')
fatal error: error in backend: IO failure on output stream: No space left on device

Environment

  • OS: Ubuntu 25
  • Arch: x86_64
  • RAM 64GB

CASR Output

Clang 21.1.8:

  "ProcFiles": [],
  "NetworkConnections": [],
  "CrashSeverity": {
    "Type": "PROBABLY_EXPLOITABLE",
    "ShortDescription": "BadInstruction",
    "Description": "Bad instruction",
    "Explanation": "The target tried to execute a malformed or privileged instruction. This may indicate that the control flow is tainted."
  },

Clang 20.1.2

 "ProcFiles": [],
  "NetworkConnections": [],
  "CrashSeverity": {
    "Type": "NOT_EXPLOITABLE",
    "ShortDescription": "SourceAv",
    "Description": "Access violation on source operand",
    "Explanation": "The target crashed on an access violation at an address matching the source operand of the current instruction. This likely indicates a read access violation."
  },

llvmbot avatar Feb 17 '26 15:02 llvmbot

The attached test file contains a null character, so it's not surprising that it cannot be reproduced in CE. However, this is a duplicate of #181741 -- look at the stack trace from this issue and note it's the same as there, because the input is similarly invalid (beyond the null character):

c:\Users\aballman\OneDrive - Intel Corporation\Desktop\crash.c:15:34: note: passing argument to parameter here
   15 | void printf(const char *a, <F2>*****\\...) __attribute__((__format__(__printf__, 1,52))00*000000000100110000);
      |                                     ^
Assertion failed: idx < size(), file F:\source\llvm-project\llvm\include\llvm/ADT/SmallVector.h, line 297
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: llvm\\out\\build\\x64-Debug\\bin\\clang.exe -cc1 -fsyntax-only "c:\\Users\\aballman\\OneDrive - Intel Corporation\\Desktop\\crash.c"
1.      c:\Users\aballman\OneDrive - Intel Corporation\Desktop\crash.c:12:11: current parser token ')'
2.      c:\Users\aballman\OneDrive - Intel Corporation\Desktop\crash.c:10:15: parsing function body 'f'
3.      c:\Users\aballman\OneDrive - Intel Corporation\Desktop\crash.c:10:15: in compound statement ('{}')
Exception Code: 0x80000003
 #0 0x00007ff70f7f72cc HandleAbort F:\source\llvm-project\llvm\lib\Support\Windows\Signals.inc:371:0
 #1 0x00007ff8b4759e77 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x99e77)
 #2 0x00007ff8b475bab9 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x9bab9)
 #3 0x00007ff8b4761715 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa1715)
 #4 0x00007ff8b4761387 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa1387)
 #5 0x00007ff8b475f351 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x9f351)
 #6 0x00007ff8b4761c7f (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa1c7f)
 #7 0x00007ff70eefa32a llvm::SmallVectorTemplateCommon<unsigned __int64, void>::operator[](unsigned __int64) F:\source\llvm-project\llvm\include\llvm\ADT\SmallVector.h:297:0
 #8 0x00007ff70eefa949 llvm::BitVector::set(unsigned int) F:\source\llvm-project\llvm\include\llvm\ADT\BitVector.h:378:0
 #9 0x00007ff70f15a5d7 llvm::SmallBitVector::set(unsigned int) F:\source\llvm-project\llvm\include\llvm\ADT\SmallBitVector.h:382:0
#10 0x00007ff717f5c238 `anonymous namespace'::CheckFormatHandler::HandleInvalidConversionSpecifier F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:7862:0
#11 0x00007ff717f5d189 `anonymous namespace'::CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:8180:0
#12 0x00007ff718899009 ParsePrintfSpecifier F:\source\llvm-project\clang\lib\AST\PrintfFormatString.cpp:421:0
#13 0x00007ff71889712d clang::analyze_format_string::ParsePrintfString(class clang::analyze_format_string::FormatStringHandler &, char const *, char const *, class clang::LangOptions const &, class clang::TargetInfo const &, bool) F:\source\llvm-project\clang\lib\AST\PrintfFormatString.cpp:437:0
#14 0x00007ff717f56915 CheckFormatString F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:9660:0
#15 0x00007ff717f58aa0 checkFormatStringExpr F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:7152:0
#16 0x00007ff717f3d519 clang::Sema::CheckFormatArguments(class llvm::ArrayRef<class clang::Expr const *>, enum clang::Sema::FormatArgumentPassingKind, class clang::StringLiteral *, unsigned int, unsigned int, enum clang::FormatStringType, enum clang::VariadicCallType, class clang::SourceLocation, class clang::SourceRange, class llvm::SmallBitVector &) F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:7473:0
#17 0x00007ff717f3d0f9 clang::Sema::CheckFormatArguments(class clang::FormatAttr const *, class llvm::ArrayRef<class clang::Expr const *>, bool, enum clang::VariadicCallType, class clang::SourceLocation, class clang::SourceRange, class llvm::SmallBitVector &) F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:7287:0
#18 0x00007ff717f22b95 clang::Sema::checkCall(class clang::NamedDecl *, class clang::FunctionProtoType const *, class clang::Expr const *, class llvm::ArrayRef<class clang::Expr const *>, bool, class clang::SourceLocation, class clang::SourceRange, enum clang::VariadicCallType) F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:4121:0
#19 0x00007ff717f21ff2 clang::Sema::CheckFunctionCall(class clang::FunctionDecl *, class clang::CallExpr *, class clang::FunctionProtoType const *) F:\source\llvm-project\clang\lib\Sema\SemaChecking.cpp:4375:0
#20 0x00007ff7148cf49b clang::Sema::BuildResolvedCallExpr(class clang::Expr *, class clang::NamedDecl *, class clang::SourceLocation, class llvm::ArrayRef<class clang::Expr *>, class clang::SourceLocation, class clang::Expr *, bool, enum clang::CallExpr::ADLCallKind) F:\source\llvm-project\clang\lib\Sema\SemaExpr.cpp:7197:0
#21 0x00007ff7148cd06d clang::Sema::BuildCallExpr(class clang::Scope *, class clang::Expr *, class clang::SourceLocation, class llvm::MutableArrayRef<class clang::Expr *>, class clang::SourceLocation, class clang::Expr *, bool, bool) F:\source\llvm-project\clang\lib\Sema\SemaExpr.cpp:6860:0
#22 0x00007ff7148ca8ef clang::Sema::ActOnCallExpr(class clang::Scope *, class clang::Expr *, class clang::SourceLocation, class llvm::MutableArrayRef<class clang::Expr *>, class clang::SourceLocation, class clang::Expr *) F:\source\llvm-project\clang\lib\Sema\SemaExpr.cpp:6600:0
#23 0x00007ff719059403 clang::Parser::ParsePostfixExpressionSuffix(class clang::ActionResult<class clang::Expr *, 1>) F:\source\llvm-project\clang\lib\Parse\ParseExpr.cpp:1926:0
#24 0x00007ff719056f0d clang::Parser::ParseCastExpression(enum clang::CastParseKind, bool, bool &, enum clang::TypoCorrectionTypeBehavior, bool, bool *) F:\source\llvm-project\clang\lib\Parse\ParseExpr.cpp:1655:0
#25 0x00007ff71905749b clang::Parser::ParseCastExpression(enum clang::CastParseKind, bool, enum clang::TypoCorrectionTypeBehavior, bool, bool *) F:\source\llvm-project\clang\lib\Parse\ParseExpr.cpp:588:0
#26 0x00007ff71904c907 clang::Parser::ParseAssignmentExpression(enum clang::TypoCorrectionTypeBehavior) F:\source\llvm-project\clang\lib\Parse\ParseExpr.cpp:92:0
#27 0x00007ff71904bb0e clang::Parser::ParseExpression(enum clang::TypoCorrectionTypeBehavior) F:\source\llvm-project\clang\lib\Parse\ParseExpr.cpp:49:0
#28 0x00007ff71910a46c clang::Parser::ParseExprStatement(enum clang::Parser::ParsedStmtContext) F:\source\llvm-project\clang\lib\Parse\ParseStmt.cpp:533:0
#29 0x00007ff719108831 clang::Parser::ParseStatementOrDeclarationAfterAttributes(class llvm::SmallVector<class clang::Stmt *, 24> &, enum clang::Parser::ParsedStmtContext, class clang::SourceLocation *, class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::LabelDecl *) F:\source\llvm-project\clang\lib\Parse\ParseStmt.cpp:253:0
#30 0x00007ff719107bd8 clang::Parser::ParseStatementOrDeclaration(class llvm::SmallVector<class clang::Stmt *, 24> &, enum clang::Parser::ParsedStmtContext, class clang::SourceLocation *, class clang::LabelDecl *) F:\source\llvm-project\clang\lib\Parse\ParseStmt.cpp:81:0
#31 0x00007ff71910cfbc clang::Parser::ParseCompoundStatementBody(bool) F:\source\llvm-project\clang\lib\Parse\ParseStmt.cpp:1173:0
#32 0x00007ff719116d4d clang::Parser::ParseFunctionStatementBody(class clang::Decl *, class clang::Parser::ParseScope &) F:\source\llvm-project\clang\lib\Parse\ParseStmt.cpp:2463:0
#33 0x00007ff718347a83 clang::Parser::ParseFunctionDefinition(class clang::ParsingDeclarator &, struct clang::Parser::ParsedTemplateInfo const &, class clang::Parser::LateParsedAttrList *) F:\source\llvm-project\clang\lib\Parse\Parser.cpp:1410:0
#34 0x00007ff718fe85c2 clang::Parser::ParseDeclGroup(class clang::ParsingDeclSpec &, enum clang::DeclaratorContext, class clang::ParsedAttributes &, struct clang::Parser::ParsedTemplateInfo &, class clang::SourceLocation *, struct clang::Parser::ForRangeInit *) F:\source\llvm-project\clang\lib\Parse\ParseDecl.cpp:2264:0
#35 0x00007ff718346044 clang::Parser::ParseDeclOrFunctionDefInternal(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec &, enum clang::AccessSpecifier) F:\source\llvm-project\clang\lib\Parse\Parser.cpp:1148:0
#36 0x00007ff7183454dd clang::Parser::ParseDeclarationOrFunctionDefinition(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec *, enum clang::AccessSpecifier) F:\source\llvm-project\clang\lib\Parse\Parser.cpp:1170:0
#37 0x00007ff718344cfd clang::Parser::ParseExternalDeclaration(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec *) F:\source\llvm-project\clang\lib\Parse\Parser.cpp:998:0
#38 0x00007ff71833d757 clang::Parser::ParseTopLevelDecl(class clang::OpaquePtr<class clang::DeclGroupRef> &, enum clang::Sema::ModuleImportState &) F:\source\llvm-project\clang\lib\Parse\Parser.cpp:706:0
#39 0x00007ff715537564 clang::ParseAST(class clang::Sema &, bool, bool) F:\source\llvm-project\clang\lib\Parse\ParseAST.cpp:170:0
#40 0x00007ff711b20ab4 clang::ASTFrontendAction::ExecuteAction(void) F:\source\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1442:0
#41 0x00007ff711b20324 clang::FrontendAction::Execute(void) F:\source\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1322:0
#42 0x00007ff70fb19f3e clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) F:\source\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1007:0
#43 0x00007ff70fcae581 clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) F:\source\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:310:0
#44 0x00007ff70eead252 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) F:\source\llvm-project\clang\tools\driver\cc1_main.cpp:304:0
#45 0x00007ff70ee9bba0 ExecuteCC1Tool F:\source\llvm-project\clang\tools\driver\driver.cpp:226:0
#46 0x00007ff70ee9c43d clang_main(int, char **, struct llvm::ToolContext const &) F:\source\llvm-project\clang\tools\driver\driver.cpp:274:0
#47 0x00007ff70eed9076 main F:\source\llvm-project\llvm\out\build\x64-Debug\tools\clang\tools\driver\clang-driver.cpp:17:0
#48 0x00007ff719f37829 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#49 0x00007ff719f37962 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#50 0x00007ff719f379ee __scrt_common_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#51 0x00007ff719f37a0e mainCRTStartup D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#52 0x00007ff9d62ae8d7 (C:\WINDOWS\System32\KERNEL32.DLL+0x2e8d7)
#53 0x00007ff9d78ec40c (C:\WINDOWS\SYSTEM32\ntdll.dll+0x8c40c)

AaronBallman avatar Feb 17 '26 23:02 AaronBallman