chjj/liburkel

`free` aborts on macOS

Closed this issue · 1 comments

running the following test crashes on macOS

  db = urkel_open(URKEL_PATH);
  tx = urkel_tx_create(db, NULL);
  ASSERT(tx != NULL);
  ASSERT(urkel_tx_insert(tx, kvs[0].key, kvs[0].value, 0));
  ASSERT(urkel_tx_commit(tx));
  ASSERT(!urkel_tx_remove(tx, kvs[1].key));
  urkel_tx_destroy(tx);

The error message

urkel_test_static(47532,0x10b41ddc0) malloc: *** error for object 0x7ffc705044d0: pointer being freed was not allocated
urkel_test_static(47532,0x10b41ddc0) malloc: *** set a breakpoint in malloc_error_break to debug

call stack

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff70d3a33a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff70df6e60 libsystem_pthread.dylib`pthread_kill + 430
    frame #2: 0x00007fff70cc1808 libsystem_c.dylib`abort + 120
    frame #3: 0x00007fff70db750b libsystem_malloc.dylib`malloc_vreport + 548
    frame #4: 0x00007fff70dba40f libsystem_malloc.dylib`malloc_report + 151
    frame #5: 0x000000010000f08a urkel_test_static`urkel_node_destroy(node=0x00000001004045a0, recurse=1) at nodes.c:362:7
    frame #6: 0x0000000100015cdb urkel_test_static`urkel_tx_destroy(tx=0x00000001004043c0) at tree.c:872:3
    frame #7: 0x0000000100003892 urkel_test_static`test_urkel_sanity at test.c:53:3
    frame #8: 0x0000000100003479 urkel_test_static`main at test.c:307:3
    frame #9: 0x0000000100003454 urkel_test_static`start + 52
chjj commented

Thanks for reporting this. That was a nasty one.