diff options
| author | Jeff Epler <jepler@gmail.com> | 2019-12-10 17:05:37 -0600 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2019-12-10 17:07:20 -0600 |
| commit | f4a5c17b5e79cf9bd02be248620d445065891a25 (patch) | |
| tree | 24a34522a434f9d137002cb29ec0b8f6dc7398e8 /supervisor | |
| parent | b22fbcd77da8c9724ed08228b89cfea53afdd5b6 (diff) | |
supervisor: external_flash: don't call m_free when it's bad
It's extremely dubious that we have these handles that we think
are to GC'd memory at a time when the gc pool may not be initialized.
Hopefully, they WERE valid GC memory and are undisturbed by the teardown
of the interpreter that can lead to this state.
In this case, don't try to m_free them, the memory will become free when
the GC heap is reinitialized.
Closes: #2338 (together with previous commit)
Diffstat (limited to 'supervisor')
| -rw-r--r-- | supervisor/shared/external_flash/external_flash.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index e7d86240b..9d38c07d8 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -371,7 +371,7 @@ static void release_ram_cache(void) { if (supervisor_cache != NULL) { free_memory(supervisor_cache); supervisor_cache = NULL; - } else { + } else if (MP_STATE_MEM(gc_pool_start)) { m_free(MP_STATE_VM(flash_ram_cache)); } MP_STATE_VM(flash_ram_cache) = NULL; @@ -419,7 +419,7 @@ static bool flush_ram_cache(bool keep_cache) { write_flash(current_sector + (i * pages_per_block + j) * SPI_FLASH_PAGE_SIZE, MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j], SPI_FLASH_PAGE_SIZE); - if (!keep_cache && supervisor_cache == NULL) { + if (!keep_cache && supervisor_cache == NULL && MP_STATE_MEM(gc_pool_start)) { m_free(MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j]); } } |
