diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-05-05 12:04:20 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-05-05 12:04:20 -0700 |
| commit | c6d539ace36b9be698a3a248793ee948ba269e68 (patch) | |
| tree | d5d0e5e385cc87932e0e1cd95e80a93a2053a4f2 /atmel-samd/main.c | |
| parent | 5ad426124bf15a50edd6aeda50a228933dee8507 (diff) | |
atmel-samd: Fix sporadic "syntax errors"
The GC was deleting memory that was in use because its scan of the
stack missed the very top. Switching to _estack fixes this by relying
on the location from the linker.
Fixes #124
Diffstat (limited to 'atmel-samd/main.c')
| -rw-r--r-- | atmel-samd/main.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 9ed1c3cd1..6184d64eb 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -115,7 +115,6 @@ void init_flash_fs(void) { f_chdrive("/flash"); } -static char *stack_top; static char heap[16384]; void reset_mp(void) { @@ -519,12 +518,6 @@ int main(void) { // initialise the cpu and peripherals samd21_init(); - int stack_dummy; - // Store the location of stack_dummy as an approximation for the top of the - // stack so the GC can account for objects that may be referenced by the - // stack between here and where gc_collect is called. - stack_top = (char*)&stack_dummy; - // Stack limit should be less than real stack size, so we have a chance // to recover from limit hit. (Limit is measured in bytes.) mp_stack_ctrl_init(); @@ -581,7 +574,7 @@ void gc_collect(void) { gc_collect_start(); // This naively collects all object references from an approximate stack // range. - gc_collect_root(&dummy, ((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t)); + gc_collect_root(&dummy, ((mp_uint_t)&_estack - (mp_uint_t)&dummy) / sizeof(mp_uint_t)); gc_collect_end(); } |
