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 segfault while compiling some SIMD code with -Wcast-align #63007

Closed
audiovention opened this issue May 30, 2023 · 6 comments
Closed

Clang segfault while compiling some SIMD code with -Wcast-align #63007

audiovention opened this issue May 30, 2023 · 6 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@audiovention
Copy link

audiovention commented May 30, 2023

I'm having trouble compiling the xsimd library (https://github.com/xtensor-stack/xsimd) with Clang. I've reproduced the issue in my codebase both on Linux (Ubuntu Clang version 15.0.7) and macOS (Apple Clang version 14.0.3 (clang-1403.0.22.14.1)).
Interesting enough on macOS I get the segfault only on Apple Silicon, not on an Intel machine, although it was segfaulting on the Intel machine with the previous version of XCode.

I've manage to create a minimum example, and narrowed down the issue to enabling the warning -Wcast-align (i.e. with the warning enabled I get a segfault during compilation, with the warning disabled the code compiles and runs fine). The code compiles and runs fine in GCC.

Here's the stack trace:

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/bin/clang++ -I/home/momchil/Desktop/AVxtensor/src -I/home/momchil/Desktop/AVxtensor/externals/xsimd/include -g -Wcast-align -std=gnu++20 -MD -MT CMakeFiles/ExampleProblemProject.dir/src/ExampleProblem.cpp.o -MF CMakeFiles/ExampleProblemProject.dir/src/ExampleProblem.cpp.o.d -o CMakeFiles/ExampleProblemProject.dir/src/ExampleProblem.cpp.o -c /home/momchil/Desktop/AVxtensor/src/ExampleProblem.cpp
1.	/home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:672:77: current parser token ')'
2.	/home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:21:1: parsing namespace 'xsimd'
3.	/home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:32:5: parsing namespace 'xsimd::kernel'
4.	/home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:652:9: parsing function body 'xsimd::kernel::from_mask'
5.	/home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:652:9: 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):
/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x31)[0x7fc0c4b07281]
/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x7fc0c4b04f9e]
/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1(_ZN4llvm3sys15CleanupOnSignalEm+0x101)[0x7fc0c4b06641]
/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1(+0xe2954f)[0x7fc0c4a2954f]
/lib/x86_64-linux-gnu/libc.so.6(+0x3bcf0)[0x7fc0c343bcf0]
/lib/x86_64-linux-gnu/libc.so.6(+0x171b81)[0x7fc0c3571b81]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang4Expr21EvaluateKnownConstIntERKNS_10ASTContextEPN4llvm15SmallVectorImplISt4pairINS_14SourceLocationENS_17PartialDiagnosticEEEE+0x277)[0x7fc0cbb794b7]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang11AlignedAttr12getAlignmentERNS_10ASTContextE+0x3a)[0x7fc0cba4f10a]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang4Decl15getMaxAlignmentEv+0x1b7)[0x7fc0cbaffa17]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang10ASTContext12getDeclAlignEPKNS_4DeclEb+0x1e)[0x7fc0cb973e1e]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x12844ed)[0x7fc0cc0844ed]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x12841a8)[0x7fc0cc0841a8]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x12848fe)[0x7fc0cc0848fe]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x12846a8)[0x7fc0cc0846a8]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x12841a8)[0x7fc0cc0841a8]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x1268c0c)[0x7fc0cc068c0c]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang4Sema14CheckCastAlignEPNS_4ExprENS_8QualTypeENS_11SourceRangeE+0x130)[0x7fc0cc068b10]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x123d1f2)[0x7fc0cc03d1f2]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang4Sema19BuildCStyleCastExprENS_14SourceLocationEPNS_14TypeSourceInfoES1_PNS_4ExprE+0x12d)[0x7fc0cc03ac4d]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang4Sema13ActOnCastExprEPNS_5ScopeENS_14SourceLocationERNS_10DeclaratorERNS_9OpaquePtrINS_8QualTypeEEES3_PNS_4ExprE+0x31f)[0x7fc0cc27a2cf]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser20ParseParenExpressionERNS0_16ParenParseOptionEbbRNS_9OpaquePtrINS_8QualTypeEEERNS_14SourceLocationE+0x1628)[0x7fc0cb8db838]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseCastExpressionENS0_13CastParseKindEbRbNS0_13TypeCastStateEbPb+0x17ee)[0x7fc0cb8d885e]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser25ParseAssignmentExpressionENS0_13TypeCastStateE+0xe1)[0x7fc0cb8d3091]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseExpressionListERN4llvm15SmallVectorImplIPNS_4ExprEEERNS2_INS_14SourceLocationEEENS1_12function_refIFvvEEEbb+0x10a)[0x7fc0cb8df03a]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser28ParsePostfixExpressionSuffixENS_12ActionResultIPNS_4ExprELb1EEE+0x14f4)[0x7fc0cb8d60b4]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseCastExpressionENS0_13CastParseKindEbRbNS0_13TypeCastStateEbPb+0xdf)[0x7fc0cb8d714f]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser25ParseAssignmentExpressionENS0_13TypeCastStateE+0xe1)[0x7fc0cb8d3091]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseExpressionListERN4llvm15SmallVectorImplIPNS_4ExprEEERNS2_INS_14SourceLocationEEENS1_12function_refIFvvEEEbb+0x10a)[0x7fc0cb8df03a]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser28ParsePostfixExpressionSuffixENS_12ActionResultIPNS_4ExprELb1EEE+0x14f4)[0x7fc0cb8d60b4]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseCastExpressionENS0_13CastParseKindEbRbNS0_13TypeCastStateEbPb+0xdf)[0x7fc0cb8d714f]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser25ParseAssignmentExpressionENS0_13TypeCastStateE+0xe1)[0x7fc0cb8d3091]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser15ParseExpressionENS0_13TypeCastStateE+0x9)[0x7fc0cb8d2f99]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser20ParseReturnStatementEv+0x107)[0x7fc0cb936d97]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser42ParseStatementOrDeclarationAfterAttributesERN4llvm11SmallVectorIPNS_4StmtELj32EEENS0_17ParsedStmtContextEPNS_14SourceLocationERNS_16ParsedAttributesESB_+0xa0d)[0x7fc0cb930bdd]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser27ParseStatementOrDeclarationERN4llvm11SmallVectorIPNS_4StmtELj32EEENS0_17ParsedStmtContextEPNS_14SourceLocationE+0x15f)[0x7fc0cb92ffbf]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser26ParseCompoundStatementBodyEb+0x7a0)[0x7fc0cb938c90]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser26ParseFunctionStatementBodyEPNS_4DeclERNS0_10ParseScopeE+0xb5)[0x7fc0cb939cc5]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser23ParseFunctionDefinitionERNS_17ParsingDeclaratorERKNS0_18ParsedTemplateInfoEPNS0_18LateParsedAttrListE+0xe12)[0x7fc0cb953ec2]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser35ParseSingleDeclarationAfterTemplateENS_17DeclaratorContextERKNS0_18ParsedTemplateInfoERNS_21ParsingDeclRAIIObjectERNS_14SourceLocationERNS_16ParsedAttributesENS_15AccessSpecifierE+0x1043)[0x7fc0cb942273]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser40ParseTemplateDeclarationOrSpecializationENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesENS_15AccessSpecifierE+0x512)[0x7fc0cb9408c2]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser36ParseDeclarationStartingWithTemplateENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesENS_15AccessSpecifierE+0xdc)[0x7fc0cb94023c]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser16ParseDeclarationENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesES5_PS2_+0x1c5)[0x7fc0cb8a1cd5]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser24ParseExternalDeclarationERNS_16ParsedAttributesEPNS_15ParsingDeclSpecE+0x11b)[0x7fc0cb95157b]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseInnerNamespaceERKN4llvm11SmallVectorINS0_18InnerNamespaceInfoELj4EEEjRNS_14SourceLocationERNS_16ParsedAttributesERNS_24BalancedDelimiterTrackerE+0xd2)[0x7fc0cb8bcd72]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser14ParseNamespaceENS_17DeclaratorContextERNS_14SourceLocationES2_+0x12e6)[0x7fc0cb8bc6b6]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser16ParseDeclarationENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesES5_PS2_+0x3c7)[0x7fc0cb8a1ed7]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser24ParseExternalDeclarationERNS_16ParsedAttributesEPNS_15ParsingDeclSpecE+0x11b)[0x7fc0cb95157b]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser19ParseInnerNamespaceERKN4llvm11SmallVectorINS0_18InnerNamespaceInfoELj4EEEjRNS_14SourceLocationERNS_16ParsedAttributesERNS_24BalancedDelimiterTrackerE+0xd2)[0x7fc0cb8bcd72]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser14ParseNamespaceENS_17DeclaratorContextERNS_14SourceLocationES2_+0x12e6)[0x7fc0cb8bc6b6]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser16ParseDeclarationENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesES5_PS2_+0x3c7)[0x7fc0cb8a1ed7]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser24ParseExternalDeclarationERNS_16ParsedAttributesEPNS_15ParsingDeclSpecE+0x11b)[0x7fc0cb95157b]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6Parser17ParseTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEERNS_4Sema17ModuleImportStateE+0x453)[0x7fc0cb94ff33]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang8ParseASTERNS_4SemaEbb+0x2ee)[0x7fc0cb88e82e]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang13CodeGenAction13ExecuteActionEv+0xd5)[0x7fc0cca81785]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang14FrontendAction7ExecuteEv+0x67)[0x7fc0cd4be4b7]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x336)[0x7fc0cd42f606]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x29a)[0x7fc0cd53ca6a]
/usr/bin/clang++(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x968)[0x55c345685598]
/usr/bin/clang++(+0x1169b)[0x55c34568369b]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(+0x228fbd2)[0x7fc0cd08fbd2]
/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xde)[0x7fc0c4a292ae]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x138)[0x7fc0cd08f6a8]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_b+0x44a)[0x7fc0cd05171a]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEEb+0x8e)[0x7fc0cd05196e]
/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x39f)[0x7fc0cd06e99f]
/usr/bin/clang++(_Z10clang_mainiPPc+0x27ef)[0x55c345682e1f]
/lib/x86_64-linux-gnu/libc.so.6(+0x23510)[0x7fc0c3423510]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x89)[0x7fc0c34235c9]
/usr/bin/clang++(_start+0x25)[0x55c3456802e5]
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/ExampleProblem-999383.cpp
clang: note: diagnostic msg: /tmp/ExampleProblem-999383.sh
clang: note: diagnostic msg: 

********************

I'm attaching the Clang generated preprocessed file and compile script, as well as a zip of a minimum example CMake project to repro.

ExampleProblem.zip
ExampleProblem-999383.zip

@audiovention
Copy link
Author

Here's the issue I created in the repo of the project I'm compiling:
xtensor-stack/xsimd#932

@Fznamznon
Copy link
Contributor

Fznamznon commented May 30, 2023

Reproduced with trunk and ExampleProblem-999383.zip. Assertion message:

clang: /source/llorg/llvm-project/clang/lib/AST/AttrImpl.cpp:243: unsigned int clang::AlignedAttr::getAlignment(clang::ASTContext&) const: Assertion `!isAlignmentDependent()' failed.

Backtrace:

0.      Program arguments: clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names
-main-file-name ExampleProblem.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-alias$
s -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -$
ys-header-deps -Wcast-align -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_$
WARF2_CFI_ASM=1 -x c++ ExampleProblem-999383.cpp
1.      /home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:672:77: current parser token ')'
2.      /home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:21:1: parsing namespace 'xsimd'
3.      /home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:32:5: parsing namespace 'xsimd::kernel'
4.      /home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:652:9: parsing function body 'xsimd::kernel::from_mask'
5.      /home/momchil/Desktop/AVxtensor/externals/xsimd/include/xsimd/arch/./xsimd_sse2.hpp:652:9: in compound statement ('{}')
 #0 0x0000000003313a08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (source/llorg/llvm-project/build/bin/clang-17+0x3313a08)
 #1 0x00000000033112ec SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f797c138b20 __restore_rt sigaction.c:0:0
 #3 0x00007f797a97537f raise (/lib64/libc.so.6+0x3737f)
 #4 0x00007f797a95fdb5 abort (/lib64/libc.so.6+0x21db5)
 #5 0x00007f797a95fc89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #6 0x00007f797a96da76 .annobin___GI___assert_fail.end assert.c:0:0
 #7 0x0000000005f3edb3 clang::AlignedAttr::getAlignment(clang::ASTContext&) const (source/llorg/llvm-project/build/bin/clang-17+0x5f3edb3)
 #8 0x0000000005ff48ce clang::Decl::getMaxAlignment() const (source/llorg/llvm-project/build/bin/clang-17+0x5ff48ce)
 #9 0x0000000005e7fcdf clang::ASTContext::getDeclAlign(clang::Decl const*, bool) const (source/llorg/llvm-project/build/bin/clang-17+0x5e7fcdf)
#10 0x000000000539fa0e getBaseAlignmentAndOffsetFromLValue(clang::Expr const*, clang::ASTContext&) (.part.2511) SemaChecking.cpp:0:0
#11 0x000000000539fbeb getBaseAlignmentAndOffsetFromPtr(clang::Expr const*, clang::ASTContext&) (.part.2509) SemaChecking.cpp:0:0
#12 0x000000000539fdc8 getAlignmentAndOffsetFromBinAddOrSub(clang::Expr const*, clang::Expr const*, bool, clang::ASTContext&) SemaChecking.cpp:0:0
#13 0x000000000539f99e getBaseAlignmentAndOffsetFromLValue(clang::Expr const*, clang::ASTContext&) (.part.2511) SemaChecking.cpp:0:0
#14 0x000000000539fbeb getBaseAlignmentAndOffsetFromPtr(clang::Expr const*, clang::ASTContext&) (.part.2509) SemaChecking.cpp:0:0
#15 0x00000000053ab5b8 clang::Sema::CheckCastAlign(clang::Expr*, clang::QualType, clang::SourceRange) (source/llorg/llvm-project/build/bin/clang-17+0x5
3ab5b8)
#16 0x00000000053834ff (anonymous namespace)::CastOperation::CheckCXXCStyleCast(bool, bool) SemaCast.cpp:0:0
#17 0x00000000053856fe clang::Sema::BuildCStyleCastExpr(clang::SourceLocation, clang::TypeSourceInfo*, clang::SourceLocation, clang::Expr*) (source/llo
rg/llvm-project/build/bin/clang-17+0x53856fe)
#18 0x00000000056af4d6 clang::Sema::ActOnCastExpr(clang::Scope*, clang::SourceLocation, clang::Declarator&, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation, clang
::Expr*) (source/llorg/llvm-project/build/bin/clang-17+0x56af4d6)
#19 0x0000000005276e16 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/local
disk2/mpodchis/source/llorg/llvm-project/build/bin/clang-17+0x5276e16)
#20 0x000000000526dee8 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (source
/llorg/llvm-project/build/bin/clang-17+0x526dee8)
#21 0x0000000005270966 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (source/llorg/
llvm-project/build/bin/clang-17+0x5270966)
#22 0x00000000052709f8 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (source/llorg/llvm-project/build/bin/clang-17+0x52709f8)
#23 0x0000000005270d1f clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::function_ref<void ()>, bool, bool) (source/llorg/
llvm-project/build/bin/clang-17+0x5270d1f)
#24 0x0000000005272a05 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (source/llorg/llvm-project/build/bin/clang-
17+0x5272a05)
#25 0x000000000526d2c9 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (source
/llorg/llvm-project/build/bin/clang-17+0x526d2c9)
#26 0x0000000005270966 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (source/llorg$
#27 0x00000000052709f8 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (source/llorg/llvm-project/build/bin/clang-17+0x52709f8)
#28 0x0000000005270d1f clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::function_ref<void ()>, bool, bool) (source/llorg/
llvm-project/build/bin/clang-17+0x5270d1f)
#29 0x0000000005272a05 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (source/llorg/llvm-project/build/bin/clang-
17+0x5272a05)
#30 0x000000000526d2c9 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (source
/llorg/llvm-project/build/bin/clang-17+0x526d2c9)
#31 0x0000000005270966 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (source/llorg/
llvm-project/build/bin/clang-17+0x5270966)
#32 0x00000000052709f8 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (source/llorg/llvm-project/build/bin/clang-17+0x52709f8)
#33 0x00000000052726e9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (source/llorg/llvm-project/build/bin/clang-17+0x52726e9)
#34 0x00000000052d2fee clang::Parser::ParseReturnStatement() (source/llorg/llvm-project/build/bin/clang-17+0x52d2fee)
#35 0x00000000052d763f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocat
ion*, clang::ParsedAttributes&, clang::ParsedAttributes&) (source/llorg/llvm-project/build/bin/clang-17+0x52d763f)
#36 0x00000000052d8d3c clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/localdi
sk2/mpodchis/source/llorg/llvm-project/build/bin/clang-17+0x52d8d3c)
#37 0x00000000052d4cb8 clang::Parser::ParseCompoundStatementBody(bool) (source/llorg/llvm-project/build/bin/clang-17+0x52d4cb8)
#38 0x00000000052d533b clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (source/llorg/llvm-project/build/bin/clang-1
7+0x52d533b)
#39 0x0000000005225f93 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/loc
aldisk2/mpodchis/source/llorg/llvm-project/build/bin/clang-17+0x5225f93)
#40 0x00000000052e9bd3 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
 clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (source/llorg/llvm-project/build/bin/clang-17+0x52e9bd3)
#41 0x00000000052f4823 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpec
ifier) (.part.348) ParseTemplate.cpp:0:0
#42 0x00000000052f4ad4 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifie
r) (source/llorg/llvm-project/build/bin/clang-17+0x52f4ad4)
#43 0x000000000524d368 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLo
cation*) (source/llorg/llvm-project/build/bin/clang-17+0x524d368)
#44 0x0000000005227090 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (source/llo
rg/llvm-project/build/bin/clang-17+0x5227090)
#45 0x000000000525ce64 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::Pars
edAttributes&, clang::BalancedDelimiterTracker&) (source/llorg/llvm-project/build/bin/clang-17+0x525ce64)
#46 0x000000000525fe1a clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (source/llorg/llvm-projec
t/build/bin/clang-17+0x525fe1a)
#47 0x000000000524d226 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLo
cation*) (source/llorg/llvm-project/build/bin/clang-17+0x524d226)
#48 0x0000000005227090 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (source/llo
rg/llvm-project/build/bin/clang-17+0x5227090)
#49 0x000000000525ce64 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::Pars
edAttributes&, clang::BalancedDelimiterTracker&) (source/llorg/llvm-project/build/bin/clang-17+0x525ce64)
#50 0x000000000525fe1a clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (source/llorg/llvm-projec
t/build/bin/clang-17+0x525fe1a)
#51 0x000000000524d226 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceL$
#52 0x0000000005227090 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (source/llo
rg/llvm-project/build/bin/clang-17+0x5227090)
#53 0x00000000052286c9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (source/llorg/llvm-pro
ject/build/bin/clang-17+0x52286c9)
#54 0x000000000521ae0a clang::ParseAST(clang::Sema&, bool, bool) (source/llorg/llvm-project/build/bin/clang-17+0x521ae0a)
#55 0x0000000004357cf8 clang::CodeGenAction::ExecuteAction() (source/llorg/llvm-project/build/bin/clang-17+0x4357cf8)
#56 0x0000000003c98809 clang::FrontendAction::Execute() (source/llorg/llvm-project/build/bin/clang-17+0x3c98809)
#57 0x0000000003c2dcf9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (source/llorg/llvm-project/build/bin/clang-17+0x3c2dcf9)
#58 0x0000000003d65a82 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (source/llorg/llvm-project/build/bin/clang-17+0x3d65a82)
#59 0x0000000000aeb938 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (source/llorg/llvm-project/build/bin/clang-17+0xaeb938)
#60 0x0000000000ae6d24 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#61 0x0000000000ae862f clang_main(int, char**, llvm::ToolContext const&) (source/llorg/llvm-project/build/bin/clang-17+0xae862f)
#62 0x0000000000a206b1 main (source/llorg/llvm-project/build/bin/clang-17+0xa206b1)
#63 0x00007f797a961493 __libc_start_main (/lib64/libc.so.6+0x23493)
#64 0x0000000000ae202e _start (source/llorg/llvm-project/build/bin/clang-17+0xae202e)

@Fznamznon Fznamznon added clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form and removed new issue labels May 30, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented May 30, 2023

@llvm/issue-subscribers-clang-frontend

@DimitryAndric
Copy link
Collaborator

Reduced:

// clang -cc1 -triple x86_64-- -S -Wcast-align ExampleProblem-min.cpp
template <class A> void from_mask() {
  alignas(A) int lut[]{};
  (long *)lut;
}

@Fznamznon Fznamznon removed the needs-reduction Large reproducer that should be reduced into a simpler form label May 30, 2023
@serge-sans-paille
Copy link
Collaborator

Potential patch: https://reviews.llvm.org/D151753

@DimitryAndric
Copy link
Collaborator

Thanks Serge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

5 participants