embed: Improve stack top estimation. · sofarocean/micropython@d2a3cd7 · GitHub
Skip to content

Commit d2a3cd7

Browse files
yamtdpgeorge
authored andcommitted
embed: Improve stack top estimation.
Obtaining the stack-top via a few function calls may yield a pointer which is too deep within the stack. So require the user to obtain it from a higher level (or via some other means). Fixes issue micropython#11781. Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
1 parent be8d660 commit d2a3cd7

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

examples/embedding/main.c

Lines changed: 8 additions & 1 deletion

ports/embed/port/embed_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#include "port/micropython_embed.h"
3535

3636
// Initialise the runtime.
37-
void mp_embed_init(void *gc_heap, size_t gc_heap_size) {
38-
mp_stack_ctrl_init();
37+
void mp_embed_init(void *gc_heap, size_t gc_heap_size, void *stack_top) {
38+
mp_stack_set_top(stack_top);
3939
gc_init(gc_heap, (uint8_t *)gc_heap + gc_heap_size);
4040
mp_init();
4141
}

ports/embed/port/micropython_embed.h

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)