[Lldb-commits] [lldb] Make ValueObjectPrinter's handling of its ValueObject pointers more principled (NFC) (PR #81314)

via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 9 15:14:24 PST 2024


jimingham wrote:

I don't think this is a lifetime issue.  If it were I would see more of the crashes at random addresses.

Whatever's going on is something odd, so I'm just trying to make the code easier to reason about.  I think in the ValueObjectPrinter's case, it's code will be cleaner if it expects to be used as it is currently used, as a one shot printer that is not responsible for the lifecycle of the ValueObject it's printing.  That was the original intent; I'm not really changing that.  I just got frustrated while trying to find the bug by inspection.  I kept going "ooh, there's an unchecked use of m_valobj, I wonder if that could cause problems?" only to follow all the paths through the code and end up convincing myself that you couldn't get here with a NULL pointer, so that wasn't the problem.  If we make it so internally to ValueObjectPrinter you can't get your hands on something that might be null, and I see another of these crashes, I'll be able to just look outside ValueObjectPrinter for the answer.

Jim



> On Feb 9, 2024, at 2:56 PM, Greg Clayton ***@***.***> wrote:
> 
> 
> None of what I suggested was mandatory. I was mainly trying to make sure things don't go away on us without us knowing about it. If we have crashes it is always hard to tell if simple heap corruption is the issue or if we are having lifetime issues. If you are not concerned about lifetime issues then you can ignore the std::weak_ptr<T> suggestion, but if you are, this would be a good way to tell as we can check std::weak_ptr<T>::expired().
> 
> Running a lldb with libgmalloc is a good way to watch for pointer lifetime issues and things being freed if someone ever has a repro case that they add to a bug.
> 
>> Reply to this email directly, view it on GitHub <https://github.com/llvm/llvm-project/pull/81314#issuecomment-1936711038>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADUPVWZQBEBTGPQVNJFPZN3YS2SQFAVCNFSM6AAAAABDCBDGDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZWG4YTCMBTHA>.
> You are receiving this because you authored the thread.
> 



https://github.com/llvm/llvm-project/pull/81314


More information about the lldb-commits mailing list