https://bugs.llvm.org/show_bug.cgi?id=52449
Bug ID: 52449
Summary: LLDB crashes on expression evaluation
Product: lldb
Version: 13.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: lldb-dev@lists.llvm.org
Reporter: wer...@gmail.com
CC: jdevliegh...@apple.com, llvm-b...@lists.llvm.org,
teempe...@gmail.com
The following code reliably crashes LLDB (built in Debug to trigger the
assertion):
```
> cat main.cc
struct Foo { static int Bar; };
int Foo::Bar = 10;
int main() { return 0; }
> lldb ./main -o "p (int*)100 + (long long)(&Foo::Bar)"
Assertion failed: isa(Val) && "cast() argument of incompatible type!",
file D:\src\llvm-project\build_x64_debug\include\llvm/Support/Casting.h, line
269
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0. Program arguments: D:\src\llvm-project\build_x64_debug\bin\lldb.exe
.\bug.exe -o p (int*)100 + (long long)(&Foo::Bar)
#0 0x7ff76373ebfc HandleAbort
D:\src\llvm-project\llvm\lib\Support\Windows\Signals.inc:408:0
#1 0x7ffd8352bc31 (C:\Windows\SYSTEM32\ucrtbased.dll+0x6bc31)
#2 0x7ffd8352d889 (C:\Windows\SYSTEM32\ucrtbased.dll+0x6d889)
#3 0x7ffd835334b5 (C:\Windows\SYSTEM32\ucrtbased.dll+0x734b5)
#4 0x7ffd83533027 (C:\Windows\SYSTEM32\ucrtbased.dll+0x73027)
#5 0x7ffd83531091 (C:\Windows\SYSTEM32\ucrtbased.dll+0x71091)
#6 0x7ffd83533a1f (C:\Windows\SYSTEM32\ucrtbased.dll+0x73a1f)
#7 0x7ffd27957cf1 llvm::cast(class llvm::Value *)
D:\src\llvm-project\build_x64_debug\include\llvm\Support\Casting.h:269:0
#8 0x7ffd2d42dbe0 llvm::DataLayout::getIndexedOffsetInType(class
llvm::Type *, class llvm::ArrayRef) const
D:\src\llvm-project\llvm\lib\IR\DataLayout.cpp:846:0
#9 0x7ffd261b2d89 InterpreterStackFrame::ResolveConstantValue(class
llvm::APInt &, class llvm::Constant const *)
D:\src\llvm-project\lldb\source\Expression\IRInterpreter.cpp:289:0
#10 0x7ffd2da23416 InterpreterStackFrame::ResolveConstant(unsigned __int64,
class llvm::Constant const *)
D:\src\llvm-project\lldb\source\Expression\IRInterpreter.cpp:345:0
#11 0x7ffd2da23e64 InterpreterStackFrame::ResolveValue(class llvm::Value
const *, class llvm::Module &)
D:\src\llvm-project\lldb\source\Expression\IRInterpreter.cpp:422:0
#12 0x7ffd2da1c439 IRInterpreter::Interpret(class llvm::Module &, class
llvm::Function &, class llvm::ArrayRef, class
lldb_private::IRExecutionUnit &, class lldb_private::Status &, unsigned
__int64, unsigned __int64, class lldb_private::ExecutionContext &)
D:\src\llvm-project\lldb\source\Expression\IRInterpreter.cpp:1276:0
#13 0x7ffd2da030e8 lldb_private::LLVMUserExpression::DoExecute(class
lldb_private::DiagnosticManager &, class lldb_private::ExecutionContext &,
class lldb_private::EvaluateExpressionOptions const &, class
std::shared_ptr &, class
std::shared_ptr &)
D:\src\llvm-project\lldb\source\Expression\LLVMUserExpression.cpp:123:0
#14 0x7ffd26cb5ad4 lldb_private::UserExpression::Execute(class
lldb_private::DiagnosticManager &, class lldb_private::ExecutionContext &,
class lldb_private::EvaluateExpressionOptions const &, class
std::shared_ptr &, class
std::shared_ptr &)
D:\src\llvm-project\lldb\source\Expression\UserExpression.cpp:397:0
#15 0x7ffd26cb6e16 lldb_private::UserExpression::Evaluate(class
lldb_private::ExecutionContext &, class lldb_private::EvaluateExpressionOptions
const &, class llvm::StringRef, class llvm::StringRef, class
std::shared_ptr &, class lldb_private::Status
&, class std::basic_string, class
std::allocator> *, class lldb_private::ValueObject *)
D:\src\llvm-project\lldb\source\Expression\UserExpression.cpp:344:0
#16 0x7ffd26eb1537 lldb_private::Target::EvaluateExpression(class
llvm::StringRef, class lldb_private::ExecutionContextScope *, class
std::shared_ptr &, class
lldb_private::EvaluateExpressionOptions const &, class std::basic_string, class std::allocator> *, class
lldb_private::ValueObject *)
D:\src\llvm-project\lldb\source\Target\Target.cpp:2416:0
#17 0x7ffd28779104
lldb_private::CommandObjectExpression::EvaluateExpression(class
llvm::StringRef, class lldb_private::Stream &, class lldb_private::Stream &,
class lldb_private::CommandReturnObject &)
D:\src\llvm-project\lldb\source\Commands\CommandObjectExpression.cpp:424:0
#18 0x7ffd28778aa6 lldb_private::CommandObjectExpression::DoExecute(class
llvm::StringRef, class lldb_private::CommandReturnObject &)
D:\src\llvm-project\lldb\source\Commands\CommandObjectExpression.cpp:653:0
#19 0x7ffd26d2c271 lldb_private::CommandObjectRaw::Execute(char const *,
class lldb_private::CommandReturnObject &)
D:\src\llvm-project\lldb\source\Interpreter\CommandObject.cpp:1015:0
#20 0x7ffd26d35a41 lldb_private::CommandInterpreter::HandleCommand(char
const *, enum lldb_private::LazyB