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



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to