diff --git a/cfg/tarantool_box_cfg.c b/cfg/tarantool_box_cfg.c index 67af7b7910c23afb578dcd06f2b21a3d9980abd6..f863dead7eac48548b4da5c9fb7b88c07d0d7f46 100644 --- a/cfg/tarantool_box_cfg.c +++ b/cfg/tarantool_box_cfg.c @@ -1814,10 +1814,10 @@ int dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) { tarantool_cfg_iterator_t iterator, *i = &iterator; - dst->username = src->username == NULL ? NULL : strdup(src->username); + if (dst->username) free(dst->username);dst->username = src->username == NULL ? NULL : strdup(src->username); if (src->username != NULL && dst->username == NULL) return CNF_NOMEMORY; - dst->bind_ipaddr = src->bind_ipaddr == NULL ? NULL : strdup(src->bind_ipaddr); + if (dst->bind_ipaddr) free(dst->bind_ipaddr);dst->bind_ipaddr = src->bind_ipaddr == NULL ? NULL : strdup(src->bind_ipaddr); if (src->bind_ipaddr != NULL && dst->bind_ipaddr == NULL) return CNF_NOMEMORY; dst->coredump = src->coredump; @@ -1827,29 +1827,29 @@ dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) { dst->slab_alloc_arena = src->slab_alloc_arena; dst->slab_alloc_minimal = src->slab_alloc_minimal; dst->slab_alloc_factor = src->slab_alloc_factor; - dst->work_dir = src->work_dir == NULL ? NULL : strdup(src->work_dir); + if (dst->work_dir) free(dst->work_dir);dst->work_dir = src->work_dir == NULL ? NULL : strdup(src->work_dir); if (src->work_dir != NULL && dst->work_dir == NULL) return CNF_NOMEMORY; - dst->pid_file = src->pid_file == NULL ? NULL : strdup(src->pid_file); + if (dst->pid_file) free(dst->pid_file);dst->pid_file = src->pid_file == NULL ? NULL : strdup(src->pid_file); if (src->pid_file != NULL && dst->pid_file == NULL) return CNF_NOMEMORY; - dst->logger = src->logger == NULL ? NULL : strdup(src->logger); + if (dst->logger) free(dst->logger);dst->logger = src->logger == NULL ? NULL : strdup(src->logger); if (src->logger != NULL && dst->logger == NULL) return CNF_NOMEMORY; dst->logger_nonblock = src->logger_nonblock; dst->io_collect_interval = src->io_collect_interval; dst->backlog = src->backlog; dst->readahead = src->readahead; - dst->snap_dir = src->snap_dir == NULL ? NULL : strdup(src->snap_dir); + if (dst->snap_dir) free(dst->snap_dir);dst->snap_dir = src->snap_dir == NULL ? NULL : strdup(src->snap_dir); if (src->snap_dir != NULL && dst->snap_dir == NULL) return CNF_NOMEMORY; - dst->wal_dir = src->wal_dir == NULL ? NULL : strdup(src->wal_dir); + if (dst->wal_dir) free(dst->wal_dir);dst->wal_dir = src->wal_dir == NULL ? NULL : strdup(src->wal_dir); if (src->wal_dir != NULL && dst->wal_dir == NULL) return CNF_NOMEMORY; dst->primary_port = src->primary_port; dst->secondary_port = src->secondary_port; dst->too_long_threshold = src->too_long_threshold; - dst->custom_proc_title = src->custom_proc_title == NULL ? NULL : strdup(src->custom_proc_title); + if (dst->custom_proc_title) free(dst->custom_proc_title);dst->custom_proc_title = src->custom_proc_title == NULL ? NULL : strdup(src->custom_proc_title); if (src->custom_proc_title != NULL && dst->custom_proc_title == NULL) return CNF_NOMEMORY; dst->memcached_port = src->memcached_port; @@ -1865,7 +1865,7 @@ dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) { dst->wal_dir_rescan_delay = src->wal_dir_rescan_delay; dst->panic_on_snap_error = src->panic_on_snap_error; dst->panic_on_wal_error = src->panic_on_wal_error; - dst->replication_source = src->replication_source == NULL ? NULL : strdup(src->replication_source); + if (dst->replication_source) free(dst->replication_source);dst->replication_source = src->replication_source == NULL ? NULL : strdup(src->replication_source); if (src->replication_source != NULL && dst->replication_source == NULL) return CNF_NOMEMORY; @@ -1889,7 +1889,7 @@ dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) { while (src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index] != NULL) { ARRAYALLOC(dst->namespace[i->idx_name__namespace]->index, i->idx_name__namespace__index + 1, _name__namespace__index, 0, 0); - dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type = src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type == NULL ? NULL : strdup(src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type); + if (dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type) free(dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type);dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type = src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type == NULL ? NULL : strdup(src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type); if (src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type != NULL && dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->type == NULL) return CNF_NOMEMORY; dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->unique = src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->unique; @@ -1903,7 +1903,7 @@ dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) { ARRAYALLOC(dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field, i->idx_name__namespace__index__key_field + 1, _name__namespace__index__key_field, 0, 0); dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->fieldno = src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->fieldno; - dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type = src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type == NULL ? NULL : strdup(src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type); + if (dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type) free(dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type);dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type = src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type == NULL ? NULL : strdup(src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type); if (src->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type != NULL && dst->namespace[i->idx_name__namespace]->index[i->idx_name__namespace__index]->key_field[i->idx_name__namespace__index__key_field]->type == NULL) return CNF_NOMEMORY; diff --git a/mod/box/index.m b/mod/box/index.m index db52f7aac6c07553d95ba71f34cac0642ba64b8d..e66626e4f4dec394ab859d74386346d54c1916b8 100644 --- a/mod/box/index.m +++ b/mod/box/index.m @@ -646,6 +646,7 @@ static void index_tree_free(struct index *index) { (void)index; + /* sptree_free? */ } void diff --git a/test/box/valgrind.sup b/test/box/valgrind.sup index e17fd7536e8025994b7b48012ee8ed87ab0751b5..19f3ab1b2383e04b222c2c6ad3700e4b5a5d716d 100644 --- a/test/box/valgrind.sup +++ b/test/box/valgrind.sup @@ -27,57 +27,19 @@ ... } - -## -## third_party -## - - ## ## libev internals ## { - <libev/libc internal stuff> + <uninitialized value> Memcheck:Param write(buf) fun:__write_nocancel fun:evpipe_write fun:ev_feed_signal fun:ev_sighandler - obj:* - fun:__epoll_wait_nocancel - fun:epoll_poll - fun:ev_run - fun:ev_loop - fun:main -} - -{ - <0 byte free> - Memcheck:Leak - fun:malloc - fun:realloc - fun:ev_realloc_emul - fun:ev_realloc - fun:epoll_destroy - fun:ev_loop_destroy - fun:ev_default_destroy - fun:tarantool_free - fun:main -} - -{ - <0 byte free> - Memcheck:Leak - fun:malloc - fun:realloc - fun:ev_realloc_emul - fun:ev_realloc - fun:ev_loop_destroy - fun:ev_default_destroy - fun:tarantool_free - fun:main + ... } { @@ -91,10 +53,7 @@ fun:ev_loop_destroy fun:ev_default_destroy fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init - fun:mod_init + ... } { @@ -107,94 +66,7 @@ fun:ev_loop_destroy fun:ev_default_destroy fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init - fun:mod_init - fun:main -} - - - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:ev_realloc_emul - fun:ev_realloc - fun:epoll_destroy - fun:ev_loop_destroy - fun:ev_default_destroy - fun:tarantool_free - fun:exit - fun:(below main) -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:ev_realloc_emul - fun:ev_realloc - fun:ev_loop_destroy - fun:ev_default_destroy - fun:tarantool_free - fun:exit - fun:(below main) -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:ev_realloc_emul - fun:ev_realloc - fun:epoll_destroy - fun:ev_loop_destroy - fun:ev_default_destroy - fun:tarantool_free - fun:exit - fun:blocking_loop - fun:spawn_child - fun:recover_init -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:ev_realloc_emul - fun:ev_realloc - fun:ev_loop_destroy - fun:ev_default_destroy - fun:tarantool_free - fun:exit - fun:blocking_loop - fun:spawn_child - fun:recover_init - fun:mod_init -} - -{ - <libev uninitialized value> - Memcheck:Param - write(buf) - fun:__write_nocancel - fun:evpipe_write - fun:ev_feed_signal - fun:ev_sighandler - obj:/lib64/libc-2.5.so - fun:__write_nocancel - fun:vsay - fun:_say - fun:fiber_serv_socket - fun:acceptor_handler - fun:fiber_loop - fun:coro_init + ... } ## @@ -206,49 +78,33 @@ Memcheck:Leak fun:malloc fun:realloc - fun:kh_resize_fid2fiber - fun:kh_put_fid2fiber - fun:register_fid - fun:fiber_create - fun:spawn_child - fun:recover_init - fun:mod_init - fun:main + fun:kh_destroy_int_ptr_map + ... } { - <insert_a_suppression_name_here> + <realloc with 0 byte> Memcheck:Leak fun:malloc fun:realloc fun:tnt_xrealloc fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:namespace_free - fun:mod_free - fun:exit - fun:(below main) + ... } { - <insert_a_suppression_name_here> + <realloc with 0 byte> Memcheck:Leak fun:malloc fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:memcached_namespace_free - fun:namespace_free - fun:mod_free - fun:exit - fun:(below main) + fun:kh_destroy_fid2fiber + fun:fiber_free + fun:tarantool_free + ... } { - <insert_a_suppression_name_here> + <realloc with 0 byte> Memcheck:Leak fun:malloc fun:realloc @@ -256,35 +112,9 @@ fun:kh_destroy_lstr_ptr_map fun:index_hash_str_free fun:index_free - fun:namespace_free - fun:mod_free - fun:exit - fun:blocking_loop - fun:spawn_child - fun:recover_init + ... } -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:memcached_namespace_free - fun:namespace_free - fun:mod_free - fun:exit - fun:blocking_loop - fun:spawn_child -} - - - - - { <realloc with 0 byte> Memcheck:Leak @@ -294,12 +124,7 @@ fun:kh_resize_lstr_ptr_map fun:kh_put_lstr_ptr_map fun:index_replace_hash_str - fun:prepare_replace - fun:box_dispatch - fun:box_process - fun:recover_row - fun:recover_wal - fun:recover_remaining_wals + ... } { @@ -307,163 +132,21 @@ Memcheck:Leak fun:malloc fun:realloc - fun:tnt_xrealloc - fun:kh_resize_lstr_ptr_map - fun:kh_put_lstr_ptr_map - fun:index_replace_hash_str - fun:prepare_replace - fun:box_dispatch - fun:box_process - fun:box_process_rw - fun:iproto_reply - fun:iproto_interact -} - -## -## realloc(ptr, 0) wal_writer -## - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:namespace_free - fun:mod_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init -} - - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:namespace_free - fun:mod_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:memcached_namespace_free - fun:namespace_free - fun:mod_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:memcached_namespace_free - fun:namespace_free - fun:mod_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:tnt_xrealloc - fun:kh_destroy_lstr_ptr_map - fun:index_hash_str_free - fun:index_free - fun:memcached_namespace_free - fun:namespace_free - fun:mod_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:kh_destroy_fid2fiber - fun:fiber_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init - fun:mod_init - fun:main -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:kh_destroy_fid2fiber - fun:fiber_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init - fun:mod_init - fun:main -} - -{ - <insert_a_suppression_name_here> - Memcheck:Leak - fun:malloc - fun:realloc - fun:kh_destroy_fid2fiber - fun:fiber_free - fun:tarantool_free - fun:blocking_loop - fun:spawn_child - fun:recover_init - fun:mod_init - fun:main + fun:kh_resize_int_ptr_map + fun:kh_put_int_ptr_map + fun:index_replace_hash_num + ... } { - <insert_a_suppression_name_here> + <realloc with 0 byte> Memcheck:Leak fun:malloc fun:realloc - fun:kh_destroy_fid2fiber - fun:fiber_free - fun:tarantool_free - fun:exit - fun:blocking_loop + fun:kh_resize_fid2fiber + fun:kh_put_fid2fiber + fun:register_fid + fun:fiber_create fun:spawn_child fun:recover_init fun:mod_init @@ -474,28 +157,21 @@ ## backtrace ## +## backtrace implementation is system specific and +## produces alot of warnings. + { <backtrace internals> Memcheck:Cond fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* + ... } { <backtrace internals> Memcheck:Value8 fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* + ... } { @@ -505,12 +181,7 @@ fun:vsnprintf fun:snprintf fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* + ... } { @@ -521,12 +192,7 @@ fun:vsnprintf fun:snprintf fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* + ... } { @@ -537,76 +203,15 @@ fun:vsnprintf fun:snprintf fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* -} - -{ - <backtrace internals> - Memcheck:Cond - fun:vfprintf - fun:vsnprintf - fun:snprintf - fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* -} - -{ - <backtrace internals> - Memcheck:Cond - fun:vfprintf - fun:vsnprintf - fun:snprintf - fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* -} - -{ - <backtrace internals> - Memcheck:Cond - fun:vfprintf - fun:vsnprintf - fun:snprintf - fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* -} - -{ - <backtrace internals> - Memcheck:Value8 - fun:backtrace - fun:fiber_info - fun:admin_dispatch - fun:admin_handler - fun:fiber_loop - fun:coro_init - obj:* + ... } - ## ## box allocations ## +## we can't directly free tuple allocations. + { <box> Memcheck:Leak @@ -638,3 +243,64 @@ fun:mod_init fun:main } + +{ + <box> + Memcheck:Leak + fun:salloc + fun:tuple_alloc + fun:prepare_replace + fun:box_dispatch + fun:box_process + fun:box_process_rw + fun:store + fun:memcached_dispatch + fun:memcached_handler + ... +} + +{ + <box> + Memcheck:Leak + fun:salloc + fun:tuple_alloc + fun:prepare_replace + fun:box_dispatch + fun:box_process + fun:box_process_rw + fun:iproto_reply + fun:iproto_interact + fun:fiber_loop + fun:coro_init + obj:* +} + +## sptree +## + +## third_party sptree implementation doesn't have +## destroy function. + +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:realloc + fun:sptree_str_t_init + fun:build_indexes + ... +} + +# iterator_init_set calls realloc only if iterator value not +# initialized or have lower depth. + +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:realloc + fun:sptree_str_t_iterator_init_set + fun:index_iterator_init_tree_str + fun:process_select + ... +}