@@ -57,7 +57,7 @@ _Py_COMP_DIAG_POP
57
57
58
58
static int
59
59
alloc_for_runtime (PyThread_type_lock * plock1 , PyThread_type_lock * plock2 ,
60
- PyThread_type_lock * plock3 )
60
+ PyThread_type_lock * plock3 , PyThread_type_lock * plock4 )
61
61
{
62
62
/* Force default allocator, since _PyRuntimeState_Fini() must
63
63
use the same allocator than this function. */
@@ -82,11 +82,20 @@ alloc_for_runtime(PyThread_type_lock *plock1, PyThread_type_lock *plock2,
82
82
return -1 ;
83
83
}
84
84
85
+ PyThread_type_lock lock4 = PyThread_allocate_lock ();
86
+ if (lock4 == NULL ) {
87
+ PyThread_free_lock (lock1 );
88
+ PyThread_free_lock (lock2 );
89
+ PyThread_free_lock (lock3 );
90
+ return -1 ;
91
+ }
92
+
85
93
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
86
94
87
95
* plock1 = lock1 ;
88
96
* plock2 = lock2 ;
89
97
* plock3 = lock3 ;
98
+ * plock4 = lock4 ;
90
99
return 0 ;
91
100
}
92
101
@@ -97,7 +106,8 @@ init_runtime(_PyRuntimeState *runtime,
97
106
Py_ssize_t unicode_next_index ,
98
107
PyThread_type_lock unicode_ids_mutex ,
99
108
PyThread_type_lock interpreters_mutex ,
100
- PyThread_type_lock xidregistry_mutex )
109
+ PyThread_type_lock xidregistry_mutex ,
110
+ PyThread_type_lock getargs_mutex )
101
111
{
102
112
if (runtime -> _initialized ) {
103
113
Py_FatalError ("runtime already initialized" );
@@ -119,6 +129,8 @@ init_runtime(_PyRuntimeState *runtime,
119
129
120
130
runtime -> xidregistry .mutex = xidregistry_mutex ;
121
131
132
+ runtime -> getargs .mutex = getargs_mutex ;
133
+
122
134
// Set it to the ID of the main thread of the main interpreter.
123
135
runtime -> main_thread = PyThread_get_thread_ident ();
124
136
@@ -141,8 +153,8 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
141
153
// is called multiple times.
142
154
Py_ssize_t unicode_next_index = runtime -> unicode_ids .next_index ;
143
155
144
- PyThread_type_lock lock1 , lock2 , lock3 ;
145
- if (alloc_for_runtime (& lock1 , & lock2 , & lock3 ) != 0 ) {
156
+ PyThread_type_lock lock1 , lock2 , lock3 , lock4 ;
157
+ if (alloc_for_runtime (& lock1 , & lock2 , & lock3 , & lock4 ) != 0 ) {
146
158
return _PyStatus_NO_MEMORY ();
147
159
}
148
160
@@ -152,7 +164,7 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
152
164
memcpy (runtime , & initial , sizeof (* runtime ));
153
165
}
154
166
init_runtime (runtime , open_code_hook , open_code_userdata , audit_hook_head ,
155
- unicode_next_index , lock1 , lock2 , lock3 );
167
+ unicode_next_index , lock1 , lock2 , lock3 , lock4 );
156
168
157
169
return _PyStatus_OK ();
158
170
}
@@ -172,6 +184,7 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime)
172
184
FREE_LOCK (runtime -> interpreters .mutex );
173
185
FREE_LOCK (runtime -> xidregistry .mutex );
174
186
FREE_LOCK (runtime -> unicode_ids .lock );
187
+ FREE_LOCK (runtime -> getargs .mutex );
175
188
176
189
#undef FREE_LOCK
177
190
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
@@ -194,6 +207,7 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
194
207
int reinit_interp = _PyThread_at_fork_reinit (& runtime -> interpreters .mutex );
195
208
int reinit_xidregistry = _PyThread_at_fork_reinit (& runtime -> xidregistry .mutex );
196
209
int reinit_unicode_ids = _PyThread_at_fork_reinit (& runtime -> unicode_ids .lock );
210
+ int reinit_getargs = _PyThread_at_fork_reinit (& runtime -> getargs .mutex );
197
211
198
212
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
199
213
@@ -204,7 +218,8 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
204
218
if (reinit_interp < 0
205
219
|| reinit_main_id < 0
206
220
|| reinit_xidregistry < 0
207
- || reinit_unicode_ids < 0 )
221
+ || reinit_unicode_ids < 0
222
+ || reinit_getargs < 0 )
208
223
{
209
224
return _PyStatus_ERR ("Failed to reinitialize runtime locks" );
210
225
0 commit comments