memory bug in cache unit tests
==37349==ERROR: AddressSanitizer: heap-use-after-free on address 0x61200000bb38 at pc 0x000101ad78d2 bp 0x7fff5e2a15d0 sp 0x7fff5e2a0d90
WRITE of size 8 at 0x61200000bb38 thread T0
#0 0x101ad78d1 in wrap_memcpy (libclang_rt.asan_osx_dynamic.dylib+0x408d1)
#1 0x101a2b718 in mdb_txn_renew0 mdb.c:2715
#2 0x101a2bde3 in mdb_txn_begin mdb.c:2850
#3 0x101a199b7 in txn_begin db_lmdb.c:265
#4 0x101996967 in kr_cache_txn_begin cache.c:134
#5 0x10196095f in test_clear (test_cache+0x10000295f)
#6 0x101a8cfb0 in _run_test (libcmocka.0.dylib+0x3fb0)
#7 0x101a8d77c in _run_group_tests (libcmocka.0.dylib+0x477c)
#8 0x10195f438 in main (test_cache+0x100001438)
#9 0x7fff8f4b45ac in start (libdyld.dylib+0x35ac)
#10 0x0 (<unknown module>)
0x61200000bb38 is located 248 bytes inside of 258-byte region [0x61200000ba40,0x61200000bb42)
freed by thread T0 here:
#0 0x101adfb89 in wrap_free (libclang_rt.asan_osx_dynamic.dylib+0x48b89)
#1 0x101996ac8 in kr_cache_txn_commit cache.c:157
#2 0x10196085b in test_fill (test_cache+0x10000285b)
#3 0x101a8cfb0 in _run_test (libcmocka.0.dylib+0x3fb0)
#4 0x101a8d77c in _run_group_tests (libcmocka.0.dylib+0x477c)
#5 0x10195f438 in main (test_cache+0x100001438)
#6 0x7fff8f4b45ac in start (libdyld.dylib+0x35ac)
#7 0x0 (<unknown module>)
previously allocated by thread T0 here:
#0 0x101adff27 in wrap_calloc (libclang_rt.asan_osx_dynamic.dylib+0x48f27)
#1 0x101a436f4 in mdb_env_open (libknot.2.dylib+0x2f6f4)
#2 0x101a197b8 in init db_lmdb.c:156
#3 0x1019966a7 in kr_cache_open cache.c:108
#4 0x10195fef9 in test_open_conventional_api (test_cache+0x100001ef9)
#5 0x101a8cfb0 in _run_test (libcmocka.0.dylib+0x3fb0)
#6 0x101a8d6f6 in _run_group_tests (libcmocka.0.dylib+0x46f6)
#7 0x10195f438 in main (test_cache+0x100001438)
#8 0x7fff8f4b45ac in start (libdyld.dylib+0x35ac)
#9 0x0 (<unknown module>)
It crashes at the end, looks like improper use in the test case.