Bug 272415 - clang 16.0.6 and 15.0.7 crash
Summary: clang 16.0.6 and 15.0.7 crash
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-07 15:43 UTC by Mark Johnston
Modified: 2023-07-07 16:52 UTC (History)
1 user (show)

See Also:


Attachments
driver script (4.12 KB, application/x-shellscript)
2023-07-07 15:44 UTC, Mark Johnston
no flags Details
source file (413.95 KB, text/plain)
2023-07-07 15:44 UTC, Mark Johnston
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston freebsd_committer freebsd_triage 2023-07-07 15:43:33 UTC
While porting libvmmapi to work on arm64, I am doing some questionable things with the preprocessor and managed to crash clang.  I verified that the problem occurs with 15.0.7 and 16.0.6; I don't have a development version of LLVM lying around to test with.

Assertion failed: (Init->containsErrors() && "Dependent code should only occur in error-recovery path."), function CheckForConstantInitializer, file /root/freebsd/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp, line 11845.                                                                                              
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.                                                                                                                                                                               
Stack dump:                                                                                                                                                                                                                                                                                                                   
0.      Program arguments: cc -O2 -pipe -fno-common -I/usr/home/markj/src/freebsd/lib/libvmmapi -g -gz=zlib -MD -MF.depend.vmmapi_machdep.o -MTvmmapi_machdep.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmiss
ing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wold-style-definition -Wno-pointer-sign -Wdate-time -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-vari
able -Wno-error=unused-but-set-parameter -Qunused-arguments -c /usr/home/markj/src/freebsd/lib/libvmmapi/amd64/vmmapi_machdep.c -o vmmapi_machdep.o            
1.      /usr/home/markj/src/freebsd/lib/libvmmapi/amd64/vmmapi_machdep.c:84:46: current parser token ';'
 #0 0x0000000005390c51 PrintStackTrace /root/freebsd/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13                                                                                                                                                                                                            
 #1 0x000000000538ef45 RunSignalHandlers /root/freebsd/contrib/llvm-project/llvm/lib/Support/Signals.cpp:104:18                                                                                                                                                                                                               
 #2 0x000000000533762e HandleCrash /root/freebsd/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:76:5                                                                                                                                                                                                          
 #3 0x00000000053377f3 CrashRecoverySignalHandler /root/freebsd/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:51                                                                                                                                                                                           
 #4 0x0000000806a81b5e handle_signal /root/freebsd/lib/libthr/thread/thr_sig.c:0:3
 #5 0x0000000806a81119 thr_sighandler /root/freebsd/lib/libthr/thread/thr_sig.c:247:1
 #6 0x00007ffffffff2d3 ([vdso]+0x2d3)
 #7 0x0000000806d3733a thr_kill /usr/obj/root/freebsd/amd64.amd64/lib/libc/thr_kill.S:4:0
 #8 0x0000000806cafe14 raise /root/freebsd/lib/libc/gen/raise.c:0:10
 #9 0x0000000806d60dc9 abort /root/freebsd/lib/libc/stdlib/abort.c:73:17
#10 0x0000000806c92f21 (/lib/libc.so.7+0x93f21)
#11 0x0000000003a46261 (/usr/bin/cc+0x3a46261)
#12 0x0000000003a47f0f AddInitializerToDecl /root/freebsd/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp:0:7
#13 0x00000000037b364c ParseDeclarationAfterDeclaratorAndAttributes /root/freebsd/contrib/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:17
#14 0x00000000037b0b17 ParseDeclGroup /root/freebsd/contrib/llvm-project/clang/lib/Parse/ParseDecl.cpp:2181:21
#15 0x000000000375cdc0 ParseDeclOrFunctionDefInternal /root/freebsd/contrib/llvm-project/clang/lib/Parse/Parser.cpp:0:10
#16 0x000000000375c76f ParseDeclarationOrFunctionDefinition /root/freebsd/contrib/llvm-project/clang/lib/Parse/Parser.cpp:1193:12
#17 0x000000000375b44d ParseExternalDeclaration /root/freebsd/contrib/llvm-project/clang/lib/Parse/Parser.cpp:0:12
#18 0x00000000037590dc ParseTopLevelDecl /root/freebsd/contrib/llvm-project/clang/lib/Parse/Parser.cpp:737:10
#19 0x000000000375338e ParseAST /root/freebsd/contrib/llvm-project/clang/lib/Parse/ParseAST.cpp:161:5
#20 0x000000000311f06f Execute /root/freebsd/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1041:10
#21 0x00000000030ae81f getPtr /root/freebsd/contrib/llvm-project/llvm/include/llvm/Support/Error.h:271:42
#22 0x00000000030ae81f operator bool /root/freebsd/contrib/llvm-project/llvm/include/llvm/Support/Error.h:234:16
#23 0x00000000030ae81f ExecuteAction /root/freebsd/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1035:23
#24 0x00000000031dedf4 ExecuteCompilerInvocation /root/freebsd/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:25
#25 0x000000000264203b cc1_main /root/freebsd/contrib/llvm-project/clang/tools/driver/cc1_main.cpp:250:15
#26 0x000000000264fb24 ExecuteCC1Tool /root/freebsd/contrib/llvm-project/clang/tools/driver/driver.cpp:317:12
#27 0x0000000002f58337 operator() /root/freebsd/contrib/llvm-project/clang/lib/Driver/Job.cpp:407:30
#28 0x0000000002f58337 callback_fn<(lambda at /root/freebsd/contrib/llvm-project/clang/lib/Driver/Job.cpp:407:22)> /root/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#29 0x0000000005337565 operator() /root/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#30 0x0000000005337565 RunSafely /root/freebsd/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:425:3
#31 0x0000000002f57f40 Execute /root/freebsd/contrib/llvm-project/clang/lib/Driver/Job.cpp:407:7
#32 0x0000000002f20ebb ExecuteCommand /root/freebsd/contrib/llvm-project/clang/lib/Driver/Compilation.cpp:200:15
#33 0x0000000002f21188 ExecuteJobs /root/freebsd/contrib/llvm-project/clang/lib/Driver/Compilation.cpp:254:13
#34 0x0000000002f38b2f empty /root/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:73:47
#35 0x0000000002f38b2f ExecuteCompilation /root/freebsd/contrib/llvm-project/clang/lib/Driver/Driver.cpp:1738:23
#36 0x000000000264f551 main /root/freebsd/contrib/llvm-project/clang/tools/driver/driver.cpp:513:21
cc: error: clang frontend command failed with exit code 134 (use -v to see invocation)
FreeBSD clang version 15.0.7 (https://github.com/llvm/llvm-project.git llvmorg-15.0.7-0-g8dfdcc7b7bf6)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/vmmapi_machdep-f24eec.c
cc: note: diagnostic msg: /tmp/vmmapi_machdep-f24eec.sh
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2023-07-07 15:44:09 UTC
Created attachment 243307 [details]
driver script
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2023-07-07 15:44:26 UTC
Created attachment 243308 [details]
source file
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2023-07-07 15:49:35 UTC
This is https://github.com/llvm/llvm-project/issues/50320, which has been reported quite a while ago, but there is no fix yet.
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2023-07-07 15:52:09 UTC
(In reply to Dimitry Andric from comment #3)
Thanks for tracking that down.  The crash only occurred because I had a typo in my code, so it's not a serious problem.

Is there any point in keeping this PR open?  Probably not.
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2023-07-07 16:52:09 UTC
(In reply to Mark Johnston from comment #4)
If you can work around it by fixing the source, then indeed, let's close it. If upstream comes up with a fix at some time, I can still reference this PR so it's logged somewhere.