This is an archive of the discontinued LLVM Phabricator instance.

[libc] Remove global constructors on File type
ClosedPublic

Authored by jhuber6 on Jul 19 2023, 4:09 PM.

Details

Summary

The File interface currently has a destructor to delete the buffer if
it is owned by the file. This is problematic for the globally allocated
stdout, stdin, and stderr files. This causes the file interface to
have global constructors to initialize the destructors to use these.
However, these never use the destructors because they don't own the
buffer. This patch removes the destructor and calls in manually in the
close implementation. The platform close should never need to access the
buffer and it needs to be done before clearing the whole thing, so this
should work.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 19 2023, 4:09 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 19 2023, 4:09 PM
jhuber6 requested review of this revision.Jul 19 2023, 4:09 PM
sivachandra accepted this revision.Jul 20 2023, 2:42 AM
This revision is now accepted and ready to land.Jul 20 2023, 2:42 AM
This revision was automatically updated to reflect the committed changes.