Issue 243727
Summary Clang compile time Segmentation fault (in trunk version clang-24 only)
Labels clang
Assignees
Reporter haoxintu
    Hi, 

repro.c
```
extern void exit (int);
extern void abort ();

void test(int x, int y)
{
	int c;

	if (x == 1) abort();
	if (y == 1) abort();

	c = x / y;

	if (::0) { c += 1; } }
unsigned g_result;
int printf(const char *, ...);
struct Node { unsigned v; struct Node *next; };
static unsigned fold(unsigned x) { return (x << 3) ^ (x >> 2) ^ 0x35u; }
static struct Node step(struct Node n, unsigned k) {
    unsigned a[4] = { k, n.v, 7u, 11u };
    for (unsigned i=0;i<4;i++) { n.v += fold(a[i] + i); }
    return n;
}
static int walk(unsigned n) {
    struct Node a={n,0}, b={3u,0};
    for(unsigned i=0;i<4;i++) {
        a=step(a,i);
 switch((a.v+i)&3u) { case 0: b.v+=a.v; break; case 1: b.v^=a.v; break;
 case 2: b.v-=i; break; default: b.v+=i+1; }
    }
    return (int)(a.v ^ b.v);
}
int main(void) {
    g_result=fold((unsigned)walk(5u));
 printf("%u\n",g_result); return 0;
}
```


```
$ clang -x c repro.c 
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /home/haoxin/research/cottontail/llvm-project/build-gcov/bin/clang-24 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name repro.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/haoxin/research/cottontail/test-gcc/runs/full-20261117-100051/findings-llvm/crash/4ddfb11272c3/repro -fcoverage-compilation-dir=/home/haoxin/research/cottontail/test-gcc/runs/full-20261117-100051/findings-llvm/crash/4ddfb11272c3/repro -resource-dir /home/haoxin/research/cottontail/llvm-project/build-gcov/lib/clang/24 -c-isystem /home/haoxin/github/se2ct/csmith-marker/include/csmith-2.3.0/ -internal-isystem /home/haoxin/research/cottontail/llvm-project/build-gcov/lib/clang/24/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../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=218 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -faddrsig -fdwarf2-cfi-asm -o /tmp/repro-904408.o -x c repro.c
1.	repro.c:13:6: current parser token '::'
2.	repro.c:5:1: parsing function body 'test'
3.	repro.c:5:1: in compound statement ('{}')
 #0 0x000055929cc929b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/haoxin/research/cottontail/llvm-project/llvm/lib/Support/Unix/Signals.inc:931:22
 #1 0x000055929cc93129 PrintStackTraceSignalHandler(void*) /home/haoxin/research/cottontail/llvm-project/llvm/lib/Support/Unix/Signals.inc:1012:23
 #2 0x000055929cc8d0b7 llvm::sys::RunSignalHandlers() /home/haoxin/research/cottontail/llvm-project/llvm/lib/Support/Signals.cpp:107:22
 #3 0x000055929cc90f6e SignalHandler(int, siginfo_t*, void*) /home/haoxin/research/cottontail/llvm-project/llvm/lib/Support/Unix/Signals.inc:457:31
 #4 0x000055929cc910ed SignalHandlerTerminate(int, siginfo_t*, void*) /home/haoxin/research/cottontail/llvm-project/llvm/lib/Support/Unix/Signals.inc:510:16
 #5 0x00007f414d242520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x42520)
  #6 0x00005592a27caa98 clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(clang::CXXScopeSpec&, bool, clang::ImplicitTypenameContext) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/Parser.cpp:2015:13
 #7 0x00005592a27ca9db clang::Parser::TryAnnotateTypeOrScopeToken(clang::ImplicitTypenameContext, bool) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/Parser.cpp:2008:51
 #8 0x00005592a29fccc6 clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1214:36
 #9 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #10 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #11 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #12 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #13 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #14 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #15 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #16 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #17 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #18 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #19 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #20 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #21 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #22 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #23 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #24 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #25 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #26 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #27 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #28 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #29 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #30 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #31 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #32 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #33 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #34 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #35 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #36 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #37 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #38 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #39 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #40 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #41 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #42 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #43 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #44 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #45 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #46 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #47 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #48 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #49 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #50 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #51 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #52 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #53 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #54 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #55 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #56 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #57 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #58 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) /home/haoxin/research/cottontail/llvm-project/clang/lib/Parse/ParseTentative.cpp:1216:37
 #59 0x00005592a29fcd1a clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameConte<truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to