File tree 3 files changed +16
-10
lines changed 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 53
53
// detect untraced object still in use
54
54
#define CLEAR_ON_SWEEP (0)
55
55
56
- #define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_WORD)
57
- #define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK)
58
-
59
56
// ATB = allocation table byte
60
57
// 0b00 = FREE -- free block
61
58
// 0b01 = HEAD -- head of a chain of blocks
@@ -209,13 +206,6 @@ bool gc_is_locked(void) {
209
206
return MP_STATE_MEM (gc_lock_depth ) != 0 ;
210
207
}
211
208
212
- // ptr should be of type voi
8000
d*
213
- #define VERIFY_PTR (ptr ) ( \
214
- ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0 /* must be aligned on a block */ \
215
- && ptr >= (void*)MP_STATE_MEM(gc_pool_start) /* must be above start of pool */ \
216
- && ptr < (void*)MP_STATE_MEM(gc_pool_end) /* must be below end of pool */ \
217
- )
218
-
219
209
#ifndef TRACE_MARK
220
210
#if DEBUG_PRINT
221
211
#define TRACE_MARK (block , ptr ) DEBUG_printf("gc_mark(%p)\n", ptr)
Original file line number Diff line number Diff line change 29
29
#include <stdint.h>
30
30
31
31
#include "py/mpconfig.h"
32
+ #include "py/mpstate.h"
32
33
#include "py/misc.h"
33
34
35
+ #define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_WORD)
36
+ #define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK)
37
+
38
+ // ptr should be of type void*
39
+ #define VERIFY_PTR (ptr ) ( \
40
+ ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0 /* must be aligned on a block */ \
41
+ && ptr >= (void*)MP_STATE_MEM(gc_pool_start) /* must be above start of pool */ \
42
+ && ptr < (void*)MP_STATE_MEM(gc_pool_end) /* must be below end of pool */ \
43
+ )
44
+
34
45
void gc_init (void * start , void * end );
35
46
void gc_deinit (void );
36
47
Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ mp_obj_t make_obj_long_lived(mp_obj_t obj, uint8_t max_depth){
126
126
if (obj == NULL ) {
127
127
return obj ;
128
128
}
129
+ // If not in the GC pool, do nothing. This can happen (at least) when
130
+ // there are frozen mp_type_bytes objects in ROM.
131
+ if (!VERIFY_PTR ((void <
54A6
span class=pl-c1>*)obj )) {
132
+ return obj ;
133
+ }
129
134
if (MP_OBJ_IS_TYPE (obj , & mp_type_fun_bc )) {
130
135
mp_obj_fun_bc_t * fun_bc = MP_OBJ_TO_PTR (obj );
131
136
return MP_OBJ_FROM_PTR (make_fun_bc_long_lived (fun_bc , max_depth ));
You can’t perform that action at this time.
0 commit comments