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-15: crash on va_arg (arm) #58794

Closed
kasperk81 opened this issue Nov 3, 2022 · 18 comments · Fixed by llvm/llvm-project-release-prs#218
Closed

clang-15: crash on va_arg (arm) #58794

kasperk81 opened this issue Nov 3, 2022 · 18 comments · Fixed by llvm/llvm-project-release-prs#218
Labels
clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport release:merged

Comments

@kasperk81
Copy link

kasperk81 commented Nov 3, 2022

Repro:

File: x.c

#include <stdarg.h>

struct T {};

struct T A(int x, ...)
{
    va_list args;
    va_start(args, x);

    struct T val = va_arg(args, struct T);

    va_end(args);

    return val;
}

command: clang-15 -target arm-linux-gnu -shared -O2 x.c

underlying assertion:

clang: /root/llvm-project/clang/include/clang/AST/Type.h:753: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.

stdout/stderr in production:

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-15/bin/clang -cc1 -triple armv4t-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name x.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu arm7tdmi -target-feature +soft-float -target-feature +soft-float-abi -target-feature -vfp2 -target-feature -vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature -fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -fp16fml -target-feature -bf16 -target-feature -mve -target-feature -mve.fp -target-feature -fpregs -target-feature +strict-align -target-abi aapcs -msoft-float -mfloat-abi soft -Wunaligned-access -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/ -resource-dir /usr/lib/llvm-15/lib/clang/15.0.2 /usr/lib/llvm-15/lib/clang/15.0.2/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/ -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o /tmp/x-b36e49.o -x c x.c
1.      <eof> parser at end of file
2.      x.c:5:10: LLVM IR generation of declaration 'A'
3.      x.c:5:10: Generating code for declaration 'A'
 #0 0x00007f47821e3451 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf04451)
 #1 0x00007f47821e118e llvm::sys::RunSignalHandlers() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf0218e)
 #2 0x00007f47821e3976 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf04976)
 #3 0x00007f4780dbd520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f4789fdfac1 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1d0fac1)
 #5 0x00007f478a04f0ba (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1d7f0ba)
 #6 0x00007f4789db9d6d (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1ae9d6d)
 #7 0x00007f4789db1988 (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1ae1988)
 #8 0x00007f4789dae620 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1ade620)
 #9 0x00007f4789d78605 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1aa8605)
#10 0x00007f4789d75e47 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1aa5e47)
#11 0x00007f4789d7173e clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1aa173e)
#12 0x00007f4789d713f5 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1aa13f5)
#13 0x00007f4789ef570c clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c2570c)
#14 0x00007f4789ef4ba1 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c24ba1)
#15 0x00007f4789f00e70 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c30e70)
#16 0x00007f4789f5ba23 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c8ba23)
#17 0x00007f4789f5c685 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c8c685)
#18 0x00007f4789f7aaf1 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1caaaf1)
#19 0x00007f4789f7431c clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1ca431c)
#20 0x00007f4789f780c5 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1ca80c5)
#21 0x00007f4789f73a1d clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1ca3a1d)
#22 0x00007f478a01aedf (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1d4aedf)
#23 0x00007f4789f51ed0 (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c81ed0)
#24 0x00007f4788d5ce69 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xa8ce69)
#25 0x00007f4789f4e775 clang::CodeGenAction::ExecuteAction() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1c7e775)
#26 0x00007f478a9840a7 clang::FrontendAction::Execute() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x26b40a7)
#27 0x00007f478a8f71b6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x26271b6)
#28 0x00007f478aa0204a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x273204a)
#29 0x0000555d1eab09e0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-15/bin/clang+0x139e0)
#30 0x0000555d1eaaebab (/usr/lib/llvm-15/bin/clang+0x11bab)
#31 0x0000555d1eaae9fc clang_main(int, char**) (/usr/lib/llvm-15/bin/clang+0x119fc)
#32 0x00007f4780da4d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#33 0x00007f4780da4e40 call_init ./csu/../csu/libc-start.c:128:20
#34 0x00007f4780da4e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#35 0x0000555d1eaab3b5 _start (/usr/lib/llvm-15/bin/clang+0xe3b5)
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 15.0.2-++20220928063118+10a54971b0d3-1~exp1~20220928063158.70
Target: arm-unknown-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/x-b4c378.c
clang: note: diagnostic msg: /tmp/x-b4c378.sh
clang: note: diagnostic msg: 

********************
@EugeneZelenko EugeneZelenko added clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Nov 3, 2022
@kasperk81
Copy link
Author

there are multiple reports referring to this assertion: https://github.com/llvm/llvm-project/search?q=getCommonPtr&type=issues. could someone please prioritize and fix it?

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 3, 2022

@llvm/issue-subscribers-clang-codegen

@yronglin
Copy link
Contributor

there are multiple reports referring to this assertion: https://github.com/llvm/llvm-project/search?q=getCommonPtr&type=issues. could someone please prioritize and fix it?

I try to fix this issue in https://reviews.llvm.org/D138137

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 16, 2022

@llvm/issue-subscribers-backend-arm

int6 pushed a commit that referenced this issue Nov 19, 2022
…e variadic arg

Fix ARMABIInfo::EmitVAAarg crash with empty record type variadic arg

Open issue: #58794

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D138137
@int6 int6 closed this as completed Nov 19, 2022
@kasperk81
Copy link
Author

/cherry-pick 80f4446

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 19, 2022

Failed to cherry-pick: 80f4446

https://github.com/llvm/llvm-project/actions/runs/3504147547

Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:

/branch <user>/<repo>/<branch>

@kasperk81
Copy link
Author

/cherry-pick 80f4446

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 19, 2022

/branch llvm/llvm-project-release-prs/issue58794

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Nov 19, 2022
…e variadic arg

Fix ARMABIInfo::EmitVAAarg crash with empty record type variadic arg

Open issue: llvm/llvm-project#58794

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D138137

(cherry picked from commit 80f4446)
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 19, 2022

/pull-request llvm/llvm-project-release-prs#218

@kasperk81
Copy link
Author

@tru, i tried to "fix" the cherry-pick command #59086,
but the bot has rudely shut it down and locked the conversation. 🤣

there should be an exception for llvm/utils/git and .github directories.

@tru
Copy link
Collaborator

tru commented Nov 19, 2022

@tru, i tried to "fix" the cherry-pick command #59086, but the bot has rudely shut it down and locked the conversation. 🤣

there should be an exception for llvm/utils/git and .github

we have used Phab for these kinds of fixes as well so far. Not sure if we want to make exceptions based on paths.

I am fine with that fix to be committed directly though. WDYT @tstellar ?

@thesamesam
Copy link
Member

I normally file a new bug for backporting to make it easier too.

@asl
Copy link
Collaborator

asl commented Nov 20, 2022

@tru, i tried to "fix" the cherry-pick command #59086, but the bot has rudely shut it down and locked the conversation. 🤣

there should be an exception for llvm/utils/git and .github directories.

The bot is correct. Main llvm repo is not using PRs.

@kasperk81
Copy link
Author

Main llvm repo is not using PRs.

doesn't make any sense to use phab for github actions stuff.. since you can't test what you are reviewing. one wrong whitespace and you need to revert and then start over..

@tru
Copy link
Collaborator

tru commented Nov 20, 2022

Main llvm repo is not using PRs.

doesn't make any sense to use phab for github actions stuff.. since you can't test what you are reviewing. one wrong whitespace and you need to revert and then start over..

I think it's a bigger decision to enable it for anything than just something we can decide here.

I usually test the actions in a personal fork before submitting.

@tstellar
Copy link
Collaborator

Phabricator is fine for these changes. You can always create a pull request against the llvm-project-release-prs repo for testing.

@tru
Copy link
Collaborator

tru commented Nov 29, 2022

/cherry-pick 80f4446

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 29, 2022

/branch llvm/llvm-project-release-prs/issue58794

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Nov 29, 2022
…e variadic arg

Fix ARMABIInfo::EmitVAAarg crash with empty record type variadic arg

Open issue: llvm/llvm-project#58794

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D138137

(cherry picked from commit 80f4446)
tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Nov 29, 2022
…e variadic arg

Fix ARMABIInfo::EmitVAAarg crash with empty record type variadic arg

Open issue: llvm/llvm-project#58794

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D138137

(cherry picked from commit 80f4446)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport release:merged
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

9 participants