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
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
Here's the issue I created in the repo of the project I'm compiling: |
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
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
@llvm/issue-subscribers-clang-frontend |
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
removed
the
needs-reduction
Large reproducer that should be reduced into a simpler form
label
May 30, 2023
Potential patch: https://reviews.llvm.org/D151753 |
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]
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:
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
The text was updated successfully, but these errors were encountered: