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

Assertion failure compiling for hybrid ("Ptr must be a pointer to Val type!") #660

Closed
acoplan-arm opened this issue Nov 7, 2022 · 1 comment

Comments

@acoplan-arm
Copy link

For the following C++ testcase:

int * __capability *f(int **p) {
    return p;
}

CHERI LLVM does the following (on multiple hybrid CHERI targets):

clang++: /local/scratch/jenkins/workspace/orello-LLVM-linux_morello_master/morello-llvm-project/llvm/lib/IR/Instructions.cpp:1491: void llvm::StoreInst::AssertOK(): Assertion `cast<PointerType>(getOperand(1)->getType()) ->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) && "Ptr must be a pointer to Val type!"' failed.
PLEASE submit a bug report to https://git.morello-project.org/morello/llvm-project/-/issues and include the crash backtrace, preprocessed source, and associated run script.
If you built clang from source, please provide a reduced test case by running:
	$LLVM_BUILD_DIR/bin/creduce_crash_testcase.py <reproducer>.sh
Stack dump:
0.	Program arguments: /morello-sdk/bin/clang++ -g -o /tmp/compiler-explorer-compiler2022107-80-1yniz0w.c5oo/output.s -mllvm --x86-asm-syntax=intel -S -target aarch64-unknown-freebsd13 --sysroot=/morello-sdk/sysroot-morello-purecap -Wall -march=morello -mabi=aapcs -fcolor-diagnostics -fno-crash-diagnostics -O2 <source>
1.	<eof> parser at end of file
2.	<source>:1:21: LLVM IR generation of declaration 'f'
3.	<source>:1:21: Generating code for declaration 'f'
 #0 0x00000000049bd80c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/morello-sdk/bin/clang+++0x49bd80c)
 #1 0x00000000049bb25e llvm::sys::RunSignalHandlers() (/morello-sdk/bin/clang+++0x49bb25e)
 #2 0x00000000049bcacd llvm::sys::CleanupOnSignal(unsigned long) (/morello-sdk/bin/clang+++0x49bcacd)
 #3 0x00000000049259a8 (/morello-sdk/bin/clang+++0x49259a8)
 #4 0x0000000004925c95 (/morello-sdk/bin/clang+++0x4925c95)
 #5 0x00007f954f0f8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #6 0x00007f954ed6f00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #7 0x00007f954ed4e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #8 0x00007f954ed4e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #9 0x00007f954ed5ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#10 0x0000000004154f95 llvm::StoreInst::AssertOK() (/morello-sdk/bin/clang+++0x4154f95)
#11 0x00000000036f3725 (/morello-sdk/bin/clang+++0x36f3725)
#12 0x0000000004dd9d2c clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) (/morello-sdk/bin/clang+++0x4dd9d2c)
#13 0x0000000004dd5a47 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/morello-sdk/bin/clang+++0x4dd5a47)
#14 0x0000000004de2fc0 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/morello-sdk/bin/clang+++0x4de2fc0)
#15 0x0000000004d67dde clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/morello-sdk/bin/clang+++0x4d67dde)
#16 0x0000000004d68bde clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/morello-sdk/bin/clang+++0x4d68bde)
#17 0x0000000004cc8b39 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/morello-sdk/bin/clang+++0x4cc8b39)
#18 0x0000000004cbe49a clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/morello-sdk/bin/clang+++0x4cbe49a)
#19 0x0000000004ccd29a clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/morello-sdk/bin/clang+++0x4ccd29a)
#20 0x00000000056d9b20 (/morello-sdk/bin/clang+++0x56d9b20)
#21 0x00000000056d7025 (/morello-sdk/bin/clang+++0x56d7025)
#22 0x0000000006044474 clang::ParseAST(clang::Sema&, bool, bool) (/morello-sdk/bin/clang+++0x6044474)
#23 0x000000000560ef12 clang::FrontendAction::Execute() (/morello-sdk/bin/clang+++0x560ef12)
#24 0x0000000005575d28 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/morello-sdk/bin/clang+++0x5575d28)
#25 0x00000000056d07d5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/morello-sdk/bin/clang+++0x56d07d5)
#26 0x0000000002fc08c9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/morello-sdk/bin/clang+++0x2fc08c9)
#27 0x0000000002fbe6ee (/morello-sdk/bin/clang+++0x2fbe6ee)
#28 0x00000000053c5022 (/morello-sdk/bin/clang+++0x53c5022)
#29 0x000000000492586c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/morello-sdk/bin/clang+++0x492586c)
#30 0x00000000053c4b8a clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/morello-sdk/bin/clang+++0x53c4b8a)
#31 0x0000000005383bfd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/morello-sdk/bin/clang+++0x5383bfd)
#32 0x0000000005384187 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/morello-sdk/bin/clang+++0x5384187)
#33 0x00000000053a313b clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/morello-sdk/bin/clang+++0x53a313b)
#34 0x0000000002fbdfb7 main (/morello-sdk/bin/clang+++0x2fbdfb7)
#35 0x00007f954ed50083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#36 0x0000000002f16f9a _start (/morello-sdk/bin/clang+++0x2f16f9a)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
@jrtc27
Copy link
Member

jrtc27 commented Aug 24, 2023

This no longer reproduces with CHERI LLVM (but still does with Morello LLVM). I can't immediately see what fixed it, so unsure if it was our bug or upstream's.

@jrtc27 jrtc27 closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants