diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd3e5890026cf683b2e6b6808145df4d65d1a94..35df21ba7b4fad564d11010572745e59f429f4ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,6 +300,7 @@ include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_BINARY_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/src/lib) include_directories(${PROJECT_SOURCE_DIR}/src/lib/small/include) +include_directories(${PROJECT_BINARY_DIR}/src/lib/small/small/include) include_directories(${PROJECT_SOURCE_DIR}/src/lib/small/third_party) include_directories(${PROJECT_SOURCE_DIR}/src/lib/core) include_directories(${PROJECT_SOURCE_DIR}/third_party) diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc index 2e0ba9e680effbd9da278cda791de628ea70622c..309d2b1f55743e9d1455299fc7513ff5457993f0 100644 --- a/src/box/lua/slab.cc +++ b/src/box/lua/slab.cc @@ -202,7 +202,7 @@ lbox_slab_info(struct lua_State *L) lua_settable(L, -3); ratio = 100 * ((double) (stats.small.used + index_stats.totals.used) - / (double) arena_size); + / (double)(arena_size + 1)); snprintf(ratio_buf, sizeof(ratio_buf), "%0.1lf%%", ratio); lua_pushstring(L, "arena_used_ratio"); @@ -271,7 +271,7 @@ lbox_runtime_info(struct lua_State *L) static int lbox_slab_check(MAYBE_UNUSED struct lua_State *L) { - slab_cache_check(SmallAlloc::get_alloc()->cache); + small_alloc_check(SmallAlloc::get_alloc()); return 0; } diff --git a/src/box/xlog.c b/src/box/xlog.c index d7549fd269bee4faa659d5087115cbd2293f32f1..5b7c550eb20dab51f35dd4d397b11d5da674f541 100644 --- a/src/box/xlog.c +++ b/src/box/xlog.c @@ -1065,7 +1065,7 @@ xlog_tx_write_plain(struct xlog *log) * now populate it with data. */ char *fixheader = (char *)log->obuf.iov[0].iov_base; - *(log_magic_t *)fixheader = row_marker; + memcpy(fixheader, &row_marker, sizeof(log_magic_t)); char *data = fixheader + sizeof(log_magic_t); data = mp_encode_uint(data, @@ -1168,7 +1168,7 @@ xlog_tx_write_zstd(struct xlog *log) offset = 0; } - *(log_magic_t *)fixheader = zrow_marker; + memcpy(fixheader, &zrow_marker, sizeof(log_magic_t)); char *data; data = fixheader + sizeof(log_magic_t); data = mp_encode_uint(data, diff --git a/src/lib/small b/src/lib/small index 8375a00818cccb329ebbd79d9a03c60c67e689da..18cc6b7383a22e1076e4bb7d46b59c4792315c89 160000 --- a/src/lib/small +++ b/src/lib/small @@ -1 +1 @@ -Subproject commit 8375a00818cccb329ebbd79d9a03c60c67e689da +Subproject commit 18cc6b7383a22e1076e4bb7d46b59c4792315c89 diff --git a/test/app-tap/module_api.c b/test/app-tap/module_api.c index e626ced07eea170922c572beb8fed833b1dad661..6ae3f9d9682f8d592531ecaf54ac6fdab711ea35 100644 --- a/test/app-tap/module_api.c +++ b/test/app-tap/module_api.c @@ -220,6 +220,8 @@ test_box_ibuf(lua_State *L) fail_unless(ibuf_used(ibuf) == 0); fail_unless(*rpos == *wpos); + ibuf_destroy(ibuf); + lua_pushboolean(L, 1); return 1; } diff --git a/test/unit/fiber.cc b/test/unit/fiber.cc index add51eea47d768f656fd0a26d5f050a83304924e..2e938d65841ec05fd95e9ce87dd2e9b64983cf23 100644 --- a/test/unit/fiber.cc +++ b/test/unit/fiber.cc @@ -216,7 +216,7 @@ fiber_stack_test() * Test a fiber with a custom stack size. */ int fiber_count = fiber_count_total(); - size_t used1 = slabc->allocated.stats.used; + size_t used1 = slab_cache_used(slabc); fiber_attr = fiber_attr_new(); fiber_attr_setstacksize(fiber_attr, default_attr.stack_size * 2); stack_expand_limit = default_attr.stack_size * 3 / 2; @@ -229,7 +229,7 @@ fiber_stack_test() fiber_sleep(0); cord_collect_garbage(cord()); fail_unless(fiber_count == fiber_count_total()); - size_t used2 = slabc->allocated.stats.used; + size_t used2 = slab_cache_used(slabc); fail_unless(used2 == used1); note("big-stack fiber not crashed"); diff --git a/test/unit/fiber_stack.c b/test/unit/fiber_stack.c index 9cd9b5319920ccbf7c1050e3654bd5d1c386ba02..b93d3de39ee0cdc0f973253c22aff7db24a36a55 100644 --- a/test/unit/fiber_stack.c +++ b/test/unit/fiber_stack.c @@ -116,7 +116,7 @@ main_f(va_list ap) diag_clear(diag_get()); - used_before = slabc->allocated.stats.used; + used_before = slab_cache_used(slabc); fiber = fiber_new_ex("test_madvise", fiber_attr, noop_f); ok(fiber != NULL, "fiber with custom stack"); @@ -130,7 +130,7 @@ main_f(va_list ap) fiber_join(fiber); inj->iparam = -1; - used_after = slabc->allocated.stats.used; + used_after = slab_cache_used(slabc); ok(used_after > used_before, "expected leak detected"); cord_collect_garbage(cord()); diff --git a/test/unit/key_def.cc b/test/unit/key_def.cc index ba1e740ee4d0b4ef3fdb700d4db5dfd3b9ee727b..7f1d4fc96e3b6b3ba1d065181f3075fa2f5d45d5 100644 --- a/test/unit/key_def.cc +++ b/test/unit/key_def.cc @@ -97,8 +97,11 @@ test_key_def_new_va(const char *format, va_list ap, bool for_func_index) /* Decode the key parts. */ const char *parts = mp_buf; uint32_t part_count = mp_decode_array(&parts); - struct key_part_def *part_def = (struct key_part_def *)region_alloc( - region, sizeof(*part_def) * part_count); + size_t stub; + struct key_part_def *part_def = + (struct key_part_def *)region_alloc_array(region, + struct key_part_def, + part_count, &stub); fail_if(part_def == NULL); fail_if(key_def_decode_parts(part_def, part_count, &parts, /*fields=*/NULL, /*field_count=*/0,