Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v2] asan: leak unit/swim.test:swim_test_encryption
@ 2020-09-10  5:30 Alexander V. Tikhonov
  2020-09-10 19:15 ` Vladislav Shpilevoy
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander V. Tikhonov @ 2020-09-10  5:30 UTC (permalink / raw)
  To: Kirill Yukhin, Vladislav Shpilevoy; +Cc: tarantool-patches

Found leak issue:

  [001] +==41031==ERROR: LeakSanitizer: detected memory leaks
  [001] +
  [001] +Direct leak of 96 byte(s) in 2 object(s) allocated from:
  [001] +    #0 0x4d8e53 in __interceptor_malloc (/tnt/test/unit/swim.test+0x4d8e53)
  [001] +    #1 0x53560f in crypto_codec_new /source/src/lib/crypto/crypto.c:239:51
  [001] +    #2 0x5299c4 in swim_scheduler_set_codec /source/src/lib/swim/swim_io.c:700:30
  [001] +    #3 0x511fe6 in swim_cluster_set_codec /source/test/unit/swim_test_utils.c:251:2
  [001] +    #4 0x50b3ae in swim_test_encryption /source/test/unit/swim.c:767:2
  [001] +    #5 0x50b3ae in main_f /source/test/unit/swim.c:1123
  [001] +    #6 0x544a3b in fiber_loop /source/src/lib/core/fiber.c:869:18
  [001] +    #7 0x5a13d0 in coro_init /source/third_party/coro/coro.c:110:3
  [001] +
  [001] +SUMMARY: AddressSanitizer: 96 byte(s) leaked in 2 allocation(s).

Prepared minimal issue reproducer:

  static void
  swim_test_encryption(void)
  {
          swim_start_test(3);
          struct swim_cluster *cluster = swim_cluster_new(2);
          swim_cluster_set_codec(cluster, CRYPTO_ALGO_AES128, CRYPTO_MODE_CBC,
                                 "1234567812345678", CRYPTO_AES128_KEY_SIZE);
          swim_cluster_delete(cluster);
          swim_finish_test();
  }

Found that memory allocation for codec creation at crypto_codec_new()
using swim_cluster_set_codec() was not any freed at the test. Added
crypto_codec_delete() in swim_scheduler_destroy() function for it.

After this fix removed susspencion on memory leak for unit/swim.test.

Closes #5283

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-5283-asan-swim
Issue: https://github.com/tarantool/tarantool/issues/5283

 asan/lsan.supp         | 4 ----
 src/lib/swim/swim_io.c | 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/asan/lsan.supp b/asan/lsan.supp
index 77b7c2cfc..46b3001e9 100644
--- a/asan/lsan.supp
+++ b/asan/lsan.supp
@@ -52,10 +52,6 @@ leak:mh_i32ptr_new
 # source: src/lib/core/exception.cc
 leak:Exception::operator new
 
-# test: unit/swim.test.lua
-# source: src/lib/swim/swim_io.c
-leak:swim_scheduler_set_codec
-
 # test: vinyl/errinj.test.lua
 # source: src/lib/core/fiber.h
 leak:fiber_cxx_invoke
diff --git a/src/lib/swim/swim_io.c b/src/lib/swim/swim_io.c
index af1092416..c8558c43e 100644
--- a/src/lib/swim/swim_io.c
+++ b/src/lib/swim/swim_io.c
@@ -402,6 +402,8 @@ swim_scheduler_destroy(struct swim_scheduler *scheduler)
 	swim_transport_destroy(&scheduler->transport);
 	swim_ev_io_stop(swim_loop(), &scheduler->output);
 	swim_scheduler_stop_input(scheduler);
+	if (scheduler->codec != NULL)
+		crypto_codec_delete(scheduler->codec);
 	assert(scheduler_count > 0);
 	if (--scheduler_count == 0)
 		swim_task_pool_destroy();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Tarantool-patches] [PATCH v2] asan: leak unit/swim.test:swim_test_encryption
  2020-09-10  5:30 [Tarantool-patches] [PATCH v2] asan: leak unit/swim.test:swim_test_encryption Alexander V. Tikhonov
@ 2020-09-10 19:15 ` Vladislav Shpilevoy
  0 siblings, 0 replies; 2+ messages in thread
From: Vladislav Shpilevoy @ 2020-09-10 19:15 UTC (permalink / raw)
  To: Alexander V. Tikhonov, Kirill Yukhin; +Cc: tarantool-patches

Hi! Thanks for the patch!

LGTM.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-10 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10  5:30 [Tarantool-patches] [PATCH v2] asan: leak unit/swim.test:swim_test_encryption Alexander V. Tikhonov
2020-09-10 19:15 ` Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox