pyln-testing: don't leak file descriptor in GossipStore
What changed, and why it matters
This is a small cleanup in a Python testing helper that makes sure a gossip-store file is closed when the object is destroyed or reopened. It fixes a file-descriptor leak in test infrastructure, not in the actual Core Lightning node software. There is no direct security impact on live Lightning nodes or user funds.
No security response required. Treat as a normal code-quality/test-hygiene improvement. If running long test suites, updating pyln-testing can avoid descriptor exhaustion during tests.
Security signals we found
Resource leak (file descriptor) fixed in testing helper
No input validation, privilege, cryptography, or network changes
Change is confined to contrib/pyln-testing, not production node code
Evidence from the diff
The patch adds a del finalizer and a close-before-reopen guard to the GossipStore class in contrib/pyln-testing/pyln/testing/gossip.py. Previously, calling open() repeatedly or letting the object be garbage-collected could leave the underlying file descriptor open. The fix closes any existing descriptor before opening a new one and closes it on object destruction. This is a resource-leak fix in a test-only utility.
Changed components
contrib/pyln-testing/pyln/testing/gossip.pyInspect captured patch +6 / −0
diff --git a/contrib/pyln-testing/pyln/testing/gossip.py b/contrib/pyln-testing/pyln/testing/gossip.py
index eb7ce99f..5c642846 100644
--- a/contrib/pyln-testing/pyln/testing/gossip.py
+++ b/contrib/pyln-testing/pyln/testing/gossip.py
@@ -16,7 +16,13 @@ class GossipStore(object):
self.path = path
self.log = logging.getLogger("GossipStore")
+ def __del__(self):
+ if self.fd is not None:
+ self.fd.close()
+
def open(self):
+ if self.fd is not None:
+ self.fd.close()
self.fd = self.path.open(mode="rb")
self.version = ord(self.fd.read(1))
if self.version < 3:
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.