[apps] Fix Python assert crash on malloc free

Change-Id: I48f86422f7d6af5227e2556e6ef531dfad696da4
This commit is contained in:
Hugo Saint-Vignes
2020-08-27 16:29:43 +02:00
committed by Émilie Feral
parent d917b2e1c9
commit 70a628f2c8
3 changed files with 30 additions and 4 deletions

View File

@@ -122,15 +122,16 @@ void MicroPython::init(void * heapStart, void * heapEnd) {
static mp_obj_t pystack[1024];
mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]);
#endif
volatile int stackTop;
void * stackTopAddress = (void *)(&stackTop);
/* We delimit the stack part that will be used by Python. The stackTop is the
* address of the first object that can be allocated on Python stack. This
* boundaries are used:
* - by gc_collect to determine where to collect roots of the objects that
* must be kept on the heap
* - to check if the maximal recursion depth has been reached. */
* - to check if the maximal recursion depth has been reached.
* Current stack pointer could go backward after initialization. A stack start
* pointer defined in main is therefore used. */
void * stackTopAddress = Ion::stackStart();
#if MP_PORT_USE_STACK_SYMBOLS
mp_stack_set_top(stackTopAddress);
size_t stackLimitInBytes = (char *)stackTopAddress - (char *)&_stack_end;