@@ -210,69 +210,19 @@ refchain_fini(PyInterpreterState *interp)
210
210
if (has_own_refchain (interp )) {
211
211
_Py_hashtable_destroy (REFCHAIN (interp ));
212
212
}
213
- // This extra branch can be removed once we start setting
214
- // interp->feature_flags *before* refchain_init() gets called.
215
- else if (REFCHAIN (interp ) != REFCHAIN (_PyInterpreterState_Main ())) {
216
- _Py_hashtable_destroy (REFCHAIN (interp ));
217
- }
218
213
REFCHAIN (interp ) = NULL ;
219
214
}
220
215
221
- /* Currently refchain_init() is called during interpreter initialization,
222
- via _PyObject_InitState(), before interp->feature_flags is set,
223
- so an interpreter may have its own refchain even though it shouldn't.
224
- Until that gets fixed, we patch it all up wherever apprpriate.
225
- maybe_fix_refchain() and move_refchain_item() can be dropped
226
- once we sort out the init order problem. */
227
-
228
- static int
229
- copy_refchain_item (_Py_hashtable_t * ht ,
230
- const void * key , const void * value ,
231
- void * user_data )
232
- {
233
- if (value != REFCHAIN_VALUE ) {
234
- assert (value == NULL );
235
- return 0 ;
236
- }
237
- _Py_hashtable_t * new_chain = (_Py_hashtable_t * )user_data ;
238
- if (_Py_hashtable_set (new_chain , key , REFCHAIN_VALUE ) < 0 ) {
239
- Py_FatalError ("_Py_hashtable_set() memory allocation failed" );
240
- }
241
- return 0 ;
242
- }
243
-
244
- static void
245
- maybe_fix_refchain (PyInterpreterState * interp )
246
- {
247
- if (has_own_refchain (interp )) {
248
- // It's okay or we haven't set the feature flags correctly yet.
249
- return ;
250
- }
251
-
252
- _Py_hashtable_t * cur_chain = REFCHAIN (interp );
253
- _Py_hashtable_t * main_chain = REFCHAIN (_PyInterpreterState_Main ());
254
- if (cur_chain == main_chain ) {
255
- // It was already fixed.
256
- return ;
257
- }
258
- REFCHAIN (interp ) = main_chain ;
259
-
260
- (void )_Py_hashtable_foreach (cur_chain , copy_refchain_item , main_chain );
261
- _Py_hashtable_destroy (cur_chain );
262
- }
263
-
264
216
bool
265
217
_PyRefchain_IsTraced (PyInterpreterState * interp , PyObject * obj )
266
218
{
267
- maybe_fix_refchain (interp );
268
219
return (_Py_hashtable_get (REFCHAIN (interp ), obj ) == REFCHAIN_VALUE );
269
220
}
270
221
271
222
272
223
static void
273
224
_PyRefchain_Trace (PyInterpreterState * interp , PyObject * obj )
274
225
{
275
- maybe_fix_refchain (interp );
276
226
if (_Py_hashtable_set (REFCHAIN (interp ), obj , REFCHAIN_VALUE ) < 0 ) {
277
227
// Use a fatal error because _Py_NewReference() cannot report
278
228
// the error to the caller.
@@ -284,7 +234,6 @@ _PyRefchain_Trace(PyInterpreterState *interp, PyObject *obj)
284
234
static void
285
235
_PyRefchain_Remove (PyInterpreterState * interp , PyObject * obj )
286
236
{
287
- maybe_fix_refchain (interp );
288
237
void * value = _Py_hashtable_steal (REFCHAIN (interp ), obj );
289
238
#ifndef NDEBUG
290
239
assert (value == REFCHAIN_VALUE );
@@ -2630,7 +2579,6 @@ _Py_PrintReferences(PyInterpreterState *interp, FILE *fp)
2630
2579
interp = _PyInterpreterState_Main ();
2631
2580
}
2632
2581
fprintf (fp , "Remaining objects:\n" );
2633
- maybe_fix_refchain (interp );
2634
2582
_Py_hashtable_foreach (REFCHAIN (interp ), _Py_PrintReference , fp );
2635
2583
}
2636
2584
@@ -2659,7 +2607,6 @@ void
2659
2607
_Py_PrintReferenceAddresses (PyInterpreterState * interp , FILE * fp )
2660
2608
{
2661
2609
fprintf (fp , "Remaining object addresses:\n" );
2662
- maybe_fix_refchain (interp );
2663
2610
_Py_hashtable_foreach (REFCHAIN (interp ), _Py_PrintReferenceAddress , fp );
2664
2611
}
2665
2612
@@ -2739,7 +2686,6 @@ _Py_GetObjects(PyObject *self, PyObject *args)
2739
2686
.limit = limit ,
2740
2687
};
2741
2688
PyInterpreterState * interp = _PyInterpreterState_GET ();
2742
- maybe_fix_refchain (interp );
2743
2689
int res = _Py_hashtable_foreach (REFCHAIN (interp ), _Py_GetObject , & data );
2744
2690
if (res == _PY_GETOBJECTS_ERROR ) {
2745
2691
Py_DECREF (list );
0 commit comments