-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLDB] Make sure FILE* is valid before trying to flush it. #169088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the
FILE*type an unspecified structure on most platforms in libc? Should we be pointing into it? If its not valid, is this an issue with line 372?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure; if you have a better suggestion for how to address/fix this issue I would be happy to hear it (I am not thrilled with this myself, but couldn't find a better way to do this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the test close the file somewhere else and we incorrectly assumed the file ownership transferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe
llvm-project/lldb/unittests/Editline/EditlineTest.cpp
Line 50 in 427c182
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I better understand the crash, its happening because
~FilePointeris closing the file, which is happening before the~LockableStreamFilethat is going to try to flush the file.I think we need to make sure the lockable stream is destroyed before the FilePointer in the Editline tests. Or we need to open the file a second time (or
dupthe file).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there is another issue with the test closing the file another time. The
PseudoTerminal ptyis not releasing the file descriptors, so it will ALSO close the file withclose(fd)when its destroyed, which is the same underlying FD that thestd::unique_ptr<FilePointer> _el_secondary_fileis pointing to.So, we're also closing the file out from under the libc
FILE*pointer or by the time theptyobject is destroyed, the file would have been closed withfclose, which should also close the fd. We're probably getting aEBADFfrom one of those two closes if we checked the return value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we changed
_el_secondary_fileto alldb::FileSPand usepty.ReleaseSecondaryFileDescriptor()to get the fd it should only be closed a single time. This should ensure we only close the file one time, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#169100 I think should clean up the ownership of the FDs to ensure they're only closed a single time.