@@ -425,7 +425,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) {
425
425
};
426
426
#endif
427
427
428
- supervisor_allocation * pystack = ( supervisor_allocation * ) 1 ;
428
+ supervisor_allocation * pystack = NULL ;
429
429
#if MICROPY_ENABLE_PYSTACK
430
430
pystack = allocate_pystack ();
431
431
#endif
@@ -767,8 +767,12 @@ STATIC void __attribute__ ((noinline)) run_safemode_py(safe_mode_t safe_mode) {
767
767
return ;
768
768
}
769
769
770
+ supervisor_allocation * pystack = NULL ;
771
+ #if MICROPY_ENABLE_PYSTACK
772
+ pystack = allocate_pystack ();
773
+ #endif
770
774
supervisor_allocation * heap = allocate_remaining_memory ();
771
- start_mp (heap );
775
+ start_mp (heap , pystack );
772
776
773
777
static const char * const safemode_py_filenames [] = {"safemode.py" , "safemode.txt" };
774
778
maybe_run_list (safemode_py_filenames , MP_ARRAY_SIZE (safemode_py_filenames ));
@@ -779,7 +783,7 @@ STATIC void __attribute__ ((noinline)) run_safemode_py(safe_mode_t safe_mode) {
779
783
set_safe_mode (SAFE_MODE_SAFEMODE_PY_ERROR );
780
784
}
781
785
782
- cleanup_after_vm (heap , _exec_result .exception );
786
+ cleanup_after_vm (heap , pystack , _exec_result .exception );
783
787
_exec_result .exception = NULL ;
784
788
}
785
789
#endif
@@ -800,7 +804,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
800
804
801
805
// Do USB setup even if boot.py is not run.
802
806
803
- supervisor_allocation * pystack = ( supervisor_allocation * ) 1 ;
807
+ supervisor_allocation * pystack = NULL ;
804
808
#if MICROPY_ENABLE_PYSTACK
805
809
pystack = allocate_pystack ();
806
810
#endif
@@ -906,7 +910,7 @@ STATIC int run_repl(void) {
906
910
int exit_code = PYEXEC_FORCED_EXIT ;
907
911
stack_resize ();
908
912
filesystem_flush ();
909
- supervisor_allocation * pystack = ( supervisor_allocation * ) 1 ;
913
+ supervisor_allocation * pystack = NULL ;
910
914
#if MICROPY_ENABLE_PYSTACK
911
915
pystack = allocate_pystack ();
912
916
#endif
0 commit comments