@@ -634,7 +634,7 @@ static PyThreadState *
634
634
new_threadstate (PyInterpreterState * interp , int init )
635
635
{
636
636
_PyRuntimeState * runtime = interp -> runtime ;
637
- PyThreadState * tstate = (PyThreadState * )PyMem_RawMalloc ( sizeof (PyThreadState ));
637
+ PyThreadState * tstate = (PyThreadState * )PyMem_RawCalloc ( 1 , sizeof (PyThreadState ));
638
638
if (tstate == NULL ) {
639
639
return NULL ;
640
640
}
@@ -643,49 +643,16 @@ new_threadstate(PyInterpreterState *interp, int init)
643
643
644
644
tstate -> recursion_limit = interp -> ceval .recursion_limit ;
645
645
tstate -> recursion_remaining = interp -> ceval .recursion_limit ;
646
- tstate -> recursion_headroom = 0 ;
647
- tstate -> tracing = 0 ;
648
- tstate -> root_cframe .use_tracing = 0 ;
649
- tstate -> root_cframe .current_frame = NULL ;
650
646
tstate -> cframe = & tstate -> root_cframe ;
651
- tstate -> gilstate_counter = 0 ;
652
- tstate -> async_exc = NULL ;
653
647
tstate -> thread_id = PyThread_get_thread_ident ();
654
648
#ifdef PY_HAVE_THREAD_NATIVE_ID
655
649
tstate -> native_thread_id = PyThread_get_thread_native_id ();
656
- #else
657
- tstate -> native_thread_id = 0 ;
658
650
#endif
659
651
660
- tstate -> dict = NULL ;
661
-
662
- tstate -> curexc_type = NULL ;
663
- tstate -> curexc_value = NULL ;
664
- tstate -> curexc_traceback = NULL ;
665
-
666
- tstate -> exc_state .exc_type = NULL ;
667
- tstate -> exc_state .exc_value = NULL ;
668
- tstate -> exc_state .exc_traceback = NULL ;
669
- tstate -> exc_state .previous_item = NULL ;
670
652
tstate -> exc_info = & tstate -> exc_state ;
671
653
672
- tstate -> c_profilefunc = NULL ;
673
- tstate -> c_tracefunc = NULL ;
674
- tstate -> c_profileobj = NULL ;
675
- tstate -> c_traceobj = NULL ;
676
-
677
- tstate -> trash_delete_nesting = 0 ;
678
- tstate -> trash_delete_later = NULL ;
679
- tstate -> on_delete = NULL ;
680
- tstate -> on_delete_data = NULL ;
681
-
682
- tstate -> coroutine_origin_tracking_depth = 0 ;
683
-
684
- tstate -> async_gen_firstiter = NULL ;
685
- tstate -> async_gen_finalizer = NULL ;
686
-
687
- tstate -> context = NULL ;
688
654
tstate -> context_ver = 1 ;
655
+
689
656
tstate -> datastack_chunk = allocate_chunk (DATA_STACK_CHUNK_SIZE , NULL );
690
657
if (tstate -> datastack_chunk == NULL ) {
691
658
PyMem_RawFree (tstate );
@@ -694,16 +661,13 @@ new_threadstate(PyInterpreterState *interp, int init)
694
661
/* If top points to entry 0, then _PyThreadState_PopFrame will try to pop this chunk */
695
662
tstate -> datastack_top = & tstate -> datastack_chunk -> data [1 ];
696
663
tstate -> datastack_limit = (PyObject * * )(((char * )tstate -> datastack_chunk ) + DATA_STACK_CHUNK_SIZE );
697
- /* Mark trace_info as uninitialized */
698
- tstate -> trace_info .code = NULL ;
699
664
700
665
if (init ) {
701
666
_PyThreadState_Init (tstate );
702
667
}
703
668
704
669
HEAD_LOCK (runtime );
705
670
tstate -> id = ++ interp -> threads .next_unique_id ;
706
- tstate -> prev = NULL ;
707
671
tstate -> next = interp -> threads .head ;
708
672
if (tstate -> next )
709
673
tstate -> next -> prev = tstate ;
0 commit comments