ElementsProject/lightning

Valgrind errors while scanning for memory leaks

Closed this issue · 2 comments

Running pyln testing with LIGHTNINGD_DEV_MEMLEAK on any test file is triggering
a valgrind error. For example test_pay.py:

LIGHTNINGD_DEV_MEMLEAK=1 pytest tests/test_pay.py -x

Fails with:

==598650== Use of uninitialised value of size 8
==598650==    at 0x24BD6E: htable_val (htable.c:152)
==598650==    by 0x24C3EA: htable_firstval_ (htable.c:167)
==598650==    by 0x24C6A0: htable_del_ (htable.c:406)
==598650==    by 0x12B93A: memleak_ptr (memleak.c:91)
==598650==    by 0x12B975: scan_for_pointers (memleak.c:146)
==598650==    by 0x12B98F: scan_for_pointers (memleak.c:147)
==598650==    by 0x12BAD1: memleak_scan_obj (memleak.c:159)
==598650==    by 0x11162B: memleak_check (libplugin.c:1745)
==598650==    by 0x114BE3: ld_command_handle (libplugin.c:1829)
==598650==    by 0x11509E: ld_read_json_one (libplugin.c:1999)
==598650==    by 0x11512E: ld_read_json (libplugin.c:2019)
==598650==    by 0x24C89D: next_plan (io.c:60)
==598650== 
{
   <insert_a_suppression_name_here>
   Memcheck:Value8
   fun:htable_val
   fun:htable_firstval_
   fun:htable_del_
   fun:memleak_ptr
   fun:scan_for_pointers
   fun:scan_for_pointers
   fun:memleak_scan_obj
   fun:memleak_check
   fun:ld_command_handle
   fun:ld_read_json_one
   fun:ld_read_json
   fun:next_plan
}

at 9afc10b

@Lagrang3 I've found python needs the envvars PYTHONMALLOC=malloc and PYTHONDEVMODE=1 to be set in in order for valgrind output to be useful.

Yes, this is why the tests suppress memleak with valgrind on. We troll through memory looking for pointers, so of course we test uninitialized memory.