box: call tuple_free from box_free
There are four problems we have to address to make this possible: 1. memtx_engine_shutdown may delete the tuple referenced by box_tuple_last so that tuple_free, which is called later by box_free, will crash trying to free it. Fix this by clearing box_tuple_last in memtx_engine_shutdown. 2. tuple_format_destroy and tuple_field_delete, called by it, expect all constraints to be detached. Let's destroy the constraints if this isn't the case. This effectively reverts commit 7a87b9a5 ("box: do not call constraint[i].destroy() in tuple_field_delete()"). 3. tuple_field_delete, called by tuple_format_destroy, expects the default value function to be unpinned. Let's unpin it if this isn't the case. To avoid linking dependencies between the tuple and box libraries, we have to introduce a virtual destructor for field_default_func. 4. The tuple_format unit test calls tuple_free after box_free. If box_free calls tuple_free by itself, this leads to a crash. Fix this by removing tuple_free and tuple_init calls from the test. Closes #9174 NO_DOC=code health NO_CHANGELOG=code health NO_TEST=checked by existing tests
Showing
- perf/memtx.cc 3 additions, 0 deletionsperf/memtx.cc
- src/box/box.cc 1 addition, 1 deletionsrc/box/box.cc
- src/box/field_default_func.c 11 additions, 0 deletionssrc/box/field_default_func.c
- src/box/field_default_func.h 9 additions, 0 deletionssrc/box/field_default_func.h
- src/box/memtx_engine.cc 9 additions, 0 deletionssrc/box/memtx_engine.cc
- src/box/tuple_format.c 5 additions, 11 deletionssrc/box/tuple_format.c
- test/unit/tuple_format.c 0 additions, 2 deletionstest/unit/tuple_format.c
Loading
Please register or sign in to comment