From f88c2139bc25efe94b6040271d134fa5ea7c4b4c Mon Sep 17 00:00:00 2001 From: Jorrit Rouwe Date: Tue, 22 Oct 2024 01:30:23 +0200 Subject: [PATCH] Make WebIDL binder temp locals threadsafe (#22772) --- tools/webidl_binder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/webidl_binder.py b/tools/webidl_binder.py index 9cdb6a83f57d..d7ce3acfc8c3 100644 --- a/tools/webidl_binder.py +++ b/tools/webidl_binder.py @@ -629,7 +629,8 @@ def make_call_args(i): if non_pointer: return_prefix += '&' if copy: - pre += ' static %s temp;\n' % type_to_c(return_type, non_pointing=True) + # Avoid sharing this static temp var between threads, which could race. + pre += ' static thread_local %s temp;\n' % type_to_c(return_type, non_pointing=True) return_prefix += '(temp = ' return_postfix += ', &temp)'