[lit] Explicitly unset timer to free thread stack (#188717)

Currently the virtual address space usage of lit fluctuates wildly, with
peak usage exceeding 4GB, which results in subsequent thread spawning
errors on 32-bit systems.

The cause of this is a circular reference in TimeoutHelper._timer (via the
callback), which causes the 8MB thread stack to not be immediately
reclaimed when the timer is cancelled.

We can avoid this by explicitly unsetting the timer.
This commit is contained in:
Nikita Popov 2026-03-26 16:57:41 +01:00 committed by GitHub
parent c9c1520dee
commit dfefc03769
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -126,6 +126,8 @@ class TimeoutHelper(object):
if not self.active():
return
self._timer.cancel()
# Break reference cycle so that thread stack is freed immediately.
self._timer = None
def active(self):
return self.timeout > 0