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

Hover crash while printing expr with recovery-asts #455

Closed
kadircet opened this issue Jul 10, 2020 · 1 comment
Closed

Hover crash while printing expr with recovery-asts #455

kadircet opened this issue Jul 10, 2020 · 1 comment
Assignees

Comments

@kadircet
Copy link
Member

void foo() {
  int x;
  int width = x;
  const int test[1] = {
      wi^dth,
      1,
  };
}

Triggering hover on ^ results in a crash, while it doesn't when triggered with -recovery-ast=0

clangd: /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:104: static bool llvm::isa_impl_cl<clang::ImplicitValueInitExpr, const clang::Expr *>::doit(const From *) [To = clang::ImplicitValueInitExpr, From = const clang::Expr *]: Assertion `Val && "isa<> used on a null pointer"' failed.
 #0 0x00000000004f1324 PrintStackTrace /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:564:13
 #1 0x00000000004f1324 PrintStackTraceSignalHandler(void*) /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:624:3
 #2 0x00000000004ef01c llvm::sys::RunSignalHandlers() /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Signals.cpp:69:18
 #3 0x00000000004f152c SignalHandler(int) /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:396:3
 #4 0x00007f6b740aa110 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14110)
 #5 0x00007f6b72625761 raise /build/glibc-M65Gwz/glibc-2.30/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007f6b7260f55b abort /build/glibc-M65Gwz/glibc-2.30/stdlib/abort.c:81:7
 #7 0x00007f6b7260f42f get_sysdep_segment_value /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:509:8
 #8 0x00007f6b7260f42f _nl_load_domain /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:970:34
 #9 0x00007f6b7261e092 (/lib/x86_64-linux-gnu/libc.so.6+0x34092)
#10 0x00000000006c1139 (/usr/local/google/home/kadircet/repos/llvm/build/bin/clangd+0x6c1139)
#11 0x00000000006c0356 (anonymous namespace)::ArrayExprEvaluator::VisitInitListExpr(clang::InitListExpr const*, clang::QualType) /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10037:7
#12 0x000000000065ec45 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:13958:9
#13 0x0000000000661883 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14037:9
#14 0x000000000065be2d EvaluateAsRValue /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14094:10
#15 0x000000000065be2d clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14140:10
#16 0x0000000000acd161 clang::clangd::(anonymous namespace)::printExprValue[abi:cxx11](clang::Expr const*, clang::ASTContext const&) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clangd/Hover.cpp:340:68
#17 0x0000000000ac7f54 printExprValue /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clangd/Hover.cpp:363:22
#18 0x0000000000ac7f54 clang::clangd::getHover(clang::clangd::ParsedAST&, clang::clangd::Position, clang::format::FormatStyle, clang::clangd::SymbolIndex const*) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clangd/Hover.cpp:832:23
#19 0x0000000000a54cd6 Expected<llvm::Optional<clang::clangd::HoverInfo> > /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Error.h:482:9
#20 0x0000000000a54cd6 operator() /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clangd/ClangdServer.cpp:621:8
#21 0x0000000000a54cd6 void llvm::detail::UniqueFunctionBase<void, llvm::Expected<clang::clangd::InputsAndAST> >::CallImpl<clang::clangd::ClangdServer::findHover(llvm::StringRef, clang::clangd::Position, llvm::unique_function<void (llvm::Expected<llvm::Optional<clang::clangd::HoverInfo> >)>)::$_12>(void*, llvm::Expected<clang::clangd::InputsAndAST>&) /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/FunctionExtras.h:195:12
#22 0x0000000000b56fe1 operator() /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clangd/TUScheduler.cpp:0:0
#23 0x0000000000b56fe1 void llvm::detail::UniqueFunctionBase<void>::CallImpl<clang::clangd::(anonymous namespace)::ASTWorker::runWithAST(llvm::StringRef, llvm::unique_function<void (llvm::Expected<clang::clangd::InputsAndAST>)>, clang::clangd::TUScheduler::ASTActionInvalidation)::$_1>(void*) /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/FunctionExtras.h:195:12
#24 0x0000000000b4d327 reset /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/Optional.h:64:9
#25 0x0000000000b4d327 ~OptionalStorage /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/Op
@hokein
Copy link
Contributor

hokein commented Jul 10, 2020

InitListExpr is a tricky AST node, it could has two forms, syntactic and semantic. RAV returns a syntactic one, but we must feed a semantic one to EvaluateAsRValue.

reproduce with a valid code:

struct Foo {
  int a[10];
};
 constexpr Foo k2 = {
   ^{1}
};

preparing a fix.

arichardson pushed a commit to arichardson/llvm-project that referenced this issue Jul 15, 2020
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
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