From 97e58519bc946daabcadc531510497c3598961a1 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 6 Nov 2026 20:25:39 +0100 Subject: Fix an accesslist reload issue where an empty-but-present changeset after a reload could potentially walk a NULL array --- tests/integration/harness.py | 5 +++++ tests/integration/test_dynamic_accesslist.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/integration/harness.py b/tests/integration/harness.py index e5ec621..f3cd0fa 100644 --- a/tests/integration/harness.py +++ b/tests/integration/harness.py @@ -135,6 +135,11 @@ class Tracker: self.log.seek(0) return self.log.read().decode("utf-8", "replace") + def reload(self): + """SIGHUP makes the accesslist reader re-read its files, which also + empties the dynamic add/delete changesets.""" + os.kill(self.process.pid, signal.SIGHUP) + def stop(self): """Returns anything the tracker complained about on the way out. diff --git a/tests/integration/test_dynamic_accesslist.py b/tests/integration/test_dynamic_accesslist.py index 7fa5fde..2072f5e 100644 --- a/tests/integration/test_dynamic_accesslist.py +++ b/tests/integration/test_dynamic_accesslist.py @@ -40,6 +40,24 @@ class DynamicAccesslist(TrackerTestCase): time.sleep(0.05) return False + def test_a_hash_added_after_a_reload_is_blocked(self): + """A reload leaves the add changeset an empty list rather than an + absent one. Adding against it walked a null array; the hash must be + blocked and the tracker must stay up.""" + OTHER = bytes(range(21, 41)) + self.feed("add.fifo", BLOCKED) + self.assertTrue(self.wait_for(BLOCKED, blocked=True), "the first hash was never blocked") + + # The reload empties the add changeset, which unblocks the first hash. + # Wait for that before adding the second, so it lands on the empty list + # the bug walked, not on the changeset before the reload has cleared it. + self.tracker.reload() + self.assertTrue(self.wait_for(BLOCKED, blocked=False), "the reload never emptied the changeset") + + self.feed("add.fifo", OTHER) + self.assertTrue(self.wait_for(OTHER, blocked=True), "the hash added after the reload was never blocked") + # tearDown's stop() surfaces any sanitizer complaint on the way out. + def test_a_hash_can_be_blocked_and_released_while_running(self): self.assertNotIn(b"failure reason", self.tracker.announce(BLOCKED)) -- cgit v1.3