diff options
| author | Jeff Epler <jepler@gmail.com> | 2021-08-27 09:02:03 -0500 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-12-08 14:29:22 +1100 |
| commit | 84071590b3d76a647fe9cd9055a089605fedc219 (patch) | |
| tree | f76c2c4aa4a3f8acfc7c28a669ae0ad762001888 /py/gc.c | |
| parent | 2283b6d68fe77b72e7beeb1bf24778834231b190 (diff) | |
py/gc: Avoid valgrind false positives.
When you want to use the valgrind memory analysis tool on MicroPython, you
can arrange to define MICROPY_DEBUG_VALGRIND to enable use of special
valgrind macros. For now, this only fixes `gc_get_ptr` so that it never
emits the diagnostic "Conditional jump or move depends on uninitialised
value(s)".
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'py/gc.c')
| -rw-r--r-- | py/gc.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -32,6 +32,10 @@ #include "py/gc.h" #include "py/runtime.h" +#if MICROPY_DEBUG_VALGRIND +#include <valgrind/memcheck.h> +#endif + #if MICROPY_ENABLE_GC #if MICROPY_DEBUG_VERBOSE // print debugging info @@ -449,6 +453,11 @@ void gc_collect_start(void) { __attribute__((no_sanitize_address)) #endif static void *gc_get_ptr(void **ptrs, int i) { + #if MICROPY_DEBUG_VALGRIND + if (!VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&ptrs[i], sizeof(*ptrs))) { + return NULL; + } + #endif return ptrs[i]; } |
