https://github.com/clayborg commented:

See inlined comments, but maybe we need to start storing a 
`std::weak_ptr<ValueObject>` instead of raw pointers to things, and possibly 
always passsing a `ValueObjectSP` object into the `ValueObjectPrinter` so it 
holds a strong reference to the value object while printing. I could see dead 
pointers causing problems and crashes.

It would be nice to also not crash, right now we do things like:
```
assert(valobj);
valobj->CrashNow();
```
If we use `std::weak_ptr<ValueObject>` instead of raw pointers or references, 
we can then call the `bool std::weak_ptr<T>::expired() const` function to see 
if the weak pointer was valid before, but the main shared pointer keeping it 
alive has been freed. This will allow us to detect issues where our backing 
object has been freed.

https://github.com/llvm/llvm-project/pull/81314
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to