[Lldb-commits] [PATCH] D116162: [lldb/python] Fix dangling Event and CommandReturnObject references

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 22 05:16:32 PST 2021


labath created this revision.
labath added reviewers: JDevlieghere, mib.
labath requested review of this revision.
Herald added a project: LLDB.

Unlike the rest of our SB objects, SBEvent and SBCommandReturnObject
have the ability to hold non-owning pointers to their non-SB
counterparts. This makes it hard to ensure the SB objects do not become
dangling once their backing object goes away.

While we could make these two objects behave like others, that would
require plubming even more shared pointers through our internal code
(Event objects are mostly prepared for it, CommandReturnObject are not).
Doing so seems unnecessarily disruptive, given that (unlike for some of
the other objects) I don't see any good reason why would someone want to
hold onto these objects after the function terminates.

For that reason, this patch implements a different approach -- the SB
objects will still hold non-owning pointers, but they will be reset to
the empty/default state as soon as the function terminates. This python
code will not crash if the user decides to store these objects -- but
the objects themselves will be useless/empty.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116162

Files:
  lldb/bindings/python/python-swigsafecast.swig
  lldb/bindings/python/python-wrapper.swig
  lldb/test/API/commands/command/script/TestCommandScript.py
  lldb/test/API/commands/command/script/persistence.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116162.395846.patch
Type: text/x-patch
Size: 6406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211222/46fffa3a/attachment.bin>


More information about the lldb-commits mailing list