[Lldb-commits] [PATCH] D69532: [LLDB][PythonFile] fix dangerous borrow semantics on python2

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 29 01:08:17 PDT 2019


labath added a comment.

So, if I understand correctly. The problem here is the final call to `fflush`, which can end up referencing a closed FILE*. Can we just not call `fflush` then? It shouldn't be really needed -- if everything goes through the same FILE* object, the C library will make sure the writes are available to anyone who tries to read through that object.

I don't buy the argument that holding onto a FD-backed object after the FD has been closed is somehow "safer" than holding onto a FILE*. They both produce undefined behavior, and given how FDs are recycled, it's very likely that this dangling object will end up writing to a random other open file -- that may be even worse than crashing. If we're not happy with that requirement then we can make `GetFile()` return a real python object, which will hold onto the lldb_private::File instance and handle these use-after-free cases in a reliable manner.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69532/new/

https://reviews.llvm.org/D69532





More information about the lldb-commits mailing list