-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] fix fd leak during lldb testsuite #118093
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
Conversation
During lldb testing dotest.py opens files to dump testcase results, but doesn't close them. This patch makes neccessary changes to fix the file descriptors leak.
@llvm/pr-subscribers-lldb Author: None (dlav-sc) ChangesDuring lldb testing dotest.py opens files to dump testcase results, but doesn't close them. This patch makes neccessary changes to fix the file descriptors leak. Full diff: https://github.com/llvm/llvm-project/pull/118093.diff 1 Files Affected:
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8884ef5933ada8..1338d16a9171e2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -865,13 +865,9 @@ def setUp(self):
session_file = self.getLogBasenameForCurrentTest() + ".log"
self.log_files.append(session_file)
- # Python 3 doesn't support unbuffered I/O in text mode. Open buffered.
- self.session = encoded_file.open(session_file, "utf-8", mode="w")
-
# Optimistically set __errored__, __failed__, __expected__ to False
# initially. If the test errored/failed, the session info
- # (self.session) is then dumped into a session specific file for
- # diagnosis.
+ # is then dumped into a session specific file for diagnosis.
self.__cleanup_errored__ = False
self.__errored__ = False
self.__failed__ = False
@@ -1235,20 +1231,25 @@ def dumpSessionInfo(self):
else:
prefix = "Success"
+ session_file = self.getLogBasenameForCurrentTest() + ".log"
+
+ # Python 3 doesn't support unbuffered I/O in text mode. Open buffered.
+ session = encoded_file.open(session_file, "utf-8", mode="w")
+
if not self.__unexpected__ and not self.__skipped__:
for test, traceback in pairs:
if test is self:
- print(traceback, file=self.session)
+ print(traceback, file=session)
import datetime
print(
"Session info generated @",
datetime.datetime.now().ctime(),
- file=self.session,
+ file=session,
)
- self.session.close()
- del self.session
+ session.close()
+ del session
# process the log files
if prefix != "Success" or lldbtest_config.log_success:
|
It leaks the fds if |
Yeah, |
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.
Happy for it to be fixed here and removed in another PR if it's unused.
Saves us resurrecting a broken function if we do want it back in future.
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'm fine either way. I probably wouldn't bother fixing it before removing it, but since you already have the PR, you might as well merge it to cover the situation David is describing.
During lldb testing dotest.py opens files to dump testcase results, but doesn't close them.
This patch makes neccessary changes to fix the file descriptors leak.