Merge pull request #1772 from tannewt/fix_gc_never_free

Check that a never free pointer is on the heap.
This commit is contained in:
Dan Halbert 2019-04-10 08:26:37 -04:00 committed by GitHub
commit 203d795bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -36,3 +36,7 @@
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
// Not connected
#define IGNORE_PIN_PA13 1
#define IGNORE_PIN_PA28 1

View File

@ -11,7 +11,7 @@ CHIP_VARIANT = SAMD21G18A
CHIP_FAMILY = samd21
# Make room for frozen libraries.
CFLAGS_INLINE_LIMIT = 65
CFLAGS_INLINE_LIMIT = 55
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = "W25Q32FV"

View File

@ -945,6 +945,10 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
#endif // Alternative gc_realloc impl
bool gc_never_free(void *ptr) {
// Check to make sure the pointer is on the heap in the first place.
if (gc_nbytes(ptr) == 0) {
return false;
}
// Pointers are stored in a linked list where each block is BYTES_PER_BLOCK long and the first
// pointer is the next block of pointers.
void ** current_reference_block = MP_STATE_MEM(permanent_pointers);