Issue 153997
Summary [clang][bytecode] Assertion `bigVal.data() && "Null pointer detected!"' failed.
Labels crash, clang:bytecode
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/KhcPv5798
```c
#include <stdint.h>

typedef union {
  struct {
    uint64_t lo;
    uint64_t hi;
  } s;
  __uint128_t n;
} u;

int foo(void) {
  const u U = {.s = {0x123ULL, 0xfffULL}};

  if (U.n)
    return 1;

  return 0;
}
```

Backtrace:
```console
clang: /root/llvm-project/llvm/lib/Support/APInt.cpp:92: void llvm::APInt::initFromArray(llvm::ArrayRef<long unsigned int>): Assertion `bigVal.data() && "Null pointer detected!"' failed.
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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fexperimental-new-constant-interpreter <source>
1.	<eof> parser at end of file
2.	<source>:11:5: LLVM IR generation of declaration 'foo'
3.	<source>:11:5: Generating code for declaration 'foo'
 #0 0x0000000004026d28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4026d28)
 #1 0x0000000004024154 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4024154)
 #2 0x0000000003f68988 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000072264be42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000072264be969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000072264be42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000072264be287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000072264be2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000072264be39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000003f3f21d (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f3f21d)
#10 0x0000000007baceb9 clang::interp::IntegralAP<false>::toAPValue(clang::ASTContext const&) const (.isra.0) Pointer.cpp:0:0
#11 0x0000000007bb44b9 clang::interp::Pointer::toRValue(clang::interp::Context const&, clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7bb44b9)
#12 0x00000000079d0e56 bool clang::interp::EvalEmitter::emitRet<(clang::interp::PrimType)13>(clang::interp::SourceInfo const&) (.part.0) EvalEmitter.cpp:0:0
#13 0x00000000079fef70 clang::interp::EvalEmitter::emitRet(clang::interp::PrimType, clang::interp::SourceInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79fef70)
#14 0x0000000007e30020 clang::interp::Compiler<clang::interp::EvalEmitter>::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7e30020)
#15 0x00000000079c5891 clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79c5891)
#16 0x00000000079b8ecf clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79b8ecf)
#17 0x00000000079328e3 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#18 0x000000000793856e EvaluateAsInt(clang::Expr const*, clang::Expr::EvalResult&, clang::ASTContext const&, clang::Expr::SideEffectsKind, (anonymous namespace)::EvalInfo&) ExprConstant.cpp:0:0
#19 0x00000000079388ae clang::Expr::EvaluateAsInt(clang::Expr::EvalResult&, clang::ASTContext const&, clang::Expr::SideEffectsKind, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79388ae)
#20 0x00000000043edeb3 (anonymous namespace)::ScalarExprEmitter::VisitMemberExpr(clang::MemberExpr*) CGExprScalar.cpp:0:0
#21 0x00000000043e6d87 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#22 0x00000000043e85fb (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#23 0x00000000043ee1fb (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#24 0x00000000043e67d1 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#25 0x00000000043eab7c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43eab7c)
#26 0x0000000004350d4d clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4350d4d)
#27 0x000000000456eb8a clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*, llvm::BasicBlock*, llvm::BasicBlock*, unsigned long, clang::Stmt::Likelihood, clang::Expr const*, clang::VarDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x456eb8a)
#28 0x0000000004501af3 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4501af3)
#29 0x00000000044fa60e clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44fa60e)
#30 0x00000000045024fc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45024fc)
#31 0x00000000045699ce clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45699ce)
#32 0x000000000457b674 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457b674)
#33 0x00000000045e6aad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45e6aad)
#34 0x00000000045e1a84 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45e1a84)
#35 0x00000000045e29c0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45e29c0)
#36 0x00000000045eccf3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#37 0x00000000049cd1b0 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#38 0x00000000049bcb84 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49bcb84)
#39 0x00000000066d75e4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66d75e4)
#40 0x00000000049c8d28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49c8d28)
#41 0x0000000004cbcd15 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4cbcd15)
#42 0x0000000004c38f6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c38f6e)
#43 0x0000000004dae5f1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4dae5f1)
#44 0x0000000000db0c0f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb0c0f)
#45 0x0000000000da786a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#46 0x0000000004a30739 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#47 0x0000000003f68e24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f68e24)
#48 0x0000000004a30d4f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#49 0x00000000049f2fbd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49f2fbd)
#50 0x00000000049f404e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49f404e)
#51 0x00000000049fbae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49fbae5)
#52 0x0000000000dad0c5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdad0c5)
#53 0x0000000000c61054 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc61054)
#54 0x000072264be29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#55 0x000072264be29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#56 0x0000000000da7315 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda7315)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to