From 97fd18a7e299f5a00207f47c1728a9bb67a2fda0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 10 Jul 2025 16:43:35 +1000 Subject: [PATCH] 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 --- tests/extmod/select_poll_eintr.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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()