summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-07-10 16:43:35 +1000
committerDamien George <damien@micropython.org>2025-07-22 23:22:05 +1000
commit97fd18a7e299f5a00207f47c1728a9bb67a2fda0 (patch)
tree2478015bc059d554a13fd703382b7aaaa6b7ba17
parent18f2e94846111ad05d49e260c59de366f3ae2489 (diff)
tests/extmod/select_poll_eintr.py: Pre-allocate global variables.
This is a workaround for the case where threading is enabled without a GIL. In such a configuration, creating a new global variable is not atomic and threads have race conditions resizing/accessing the global dict. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--tests/extmod/select_poll_eintr.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/extmod/select_poll_eintr.py b/tests/extmod/select_poll_eintr.py
index d9e9b3190..fdc5ee507 100644
--- a/tests/extmod/select_poll_eintr.py
+++ b/tests/extmod/select_poll_eintr.py
@@ -33,6 +33,14 @@ def thread_main():
print("thread gc end")
+# Pre-allocate global variables here so the global dict is not resized by the main
+# thread while the secondary thread runs. This is a workaround for the bug described
+# in https://github.com/micropython/micropython/pull/11604
+poller = None
+t0 = None
+result = None
+dt_ms = None
+
# Start a thread to interrupt the main thread during its call to poll.
lock = _thread.allocate_lock()
lock.acquire()