<div dir="ltr">Hi Cfe-dev, Richard,<div><br></div><div>I've run into a test case in LLDB where we crash evaluating an expression in the following program:</div><div><br></div><div><font face="monospace, monospace">class Foo {};</font></div><div><font face="monospace, monospace">class Bar : public Foo {};</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">class Base {</font></div><div><font face="monospace, monospace">public:</font></div><div><font face="monospace, monospace">  virtual Foo* baz() { return nullptr; }</font></div><div><font face="monospace, monospace">};</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">class Derived : public Base {</font></div><div><font face="monospace, monospace">public:</font></div><div><font face="monospace, monospace">  Bar* baz() override { return nullptr; }</font></div><div><font face="monospace, monospace">};</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">int main() {</font></div><div><font face="monospace, monospace">  Derived d;</font></div><div><font face="monospace, monospace">  Base *b = *d;</font></div><div><font face="monospace, monospace">  b->baz(); // Break here and eval 'd.baz()' to crash.</font></div><div><font face="monospace, monospace">  return 0;</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>LLDB is crashing in IRGen when we call the CXXRecordDecl::bases() method for the Bar class. (I think this is being called to determine whether we need to fix up the pointer returned from Derived::baz()). Because the CXXRecordDecl for Bar is generated by DWARFASTParserClang as a minimal, lazily completed decl (and is then imported into a different context for good measure), and because no other operations on Bar force it to be completed, it's still incomplete when we call bases(). In particular, the DerivedData field is still null: it's the access to this field that causes the crash.</div><div><br></div><div>I don't grok the model for lazy decl completion/import well enough to know exactly how to proceed (Is there a good source explaining it?). I know that some operations on a Decl will cause that Decl to be completed automatically. Should calling 'bases()' also trigger completion? Or should that be the responsibility of callers of bases()? (I tested forcing completion in CXXBasePaths::lookupInBases(…) and that fixed my issue, but it's not clear to me that that's the Right Thing to do here).</div><div><br></div><div>Cheers,</div><div>Lang.</div></div>