Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asan: flaky memory leak on mh_i32ptr_new #5330

Open
avtikhon opened this issue Sep 25, 2020 · 0 comments
Open

asan: flaky memory leak on mh_i32ptr_new #5330

avtikhon opened this issue Sep 25, 2020 · 0 comments
Labels

Comments

@avtikhon
Copy link
Contributor

Tarantool version:
2.6.0-78-gc1f72aeb7
Target: Linux-x86_64-RelWithDebInfo
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=ON
Compiler: /usr/bin/clang-8 /usr/bin/clang++-8
C_FLAGS: -Wno-unknown-pragmas -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -msse2 -fsanitize=address -fsanitize-blacklist=/source/asan/asan.supp -std=c11 -Wall -Wextra -Wno-strict-aliasing -fsanitize=alignment,bool,bounds,builtin,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,return,shift,unreachable,vla-bound -fno-sanitize-recover=alignment,bool,bounds,builtin,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,return,shift,unreachable,vla-bound -Wno-char-subscripts -Wno-gnu-alignof-expression -Werror
CXX_FLAGS: -Wno-unknown-pragmas -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -msse2 -fsanitize=address -fsanitize-blacklist=/source/asan/asan.supp -std=c++11 -Wall -Wextra -Wno-strict-aliasing -fsanitize=alignment,bool,bounds,builtin,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,return,shift,unreachable,vla-bound -fno-sanitize-recover=alignment,bool,bounds,builtin,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,return,shift,unreachable,vla-bound -Wno-char-subscripts -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Werror

OS version:
Debian GNU/Linux buster/sid

Bug description:
In asan/lsan check found memory leaks:

Direct leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa161d8 in mh_i32ptr_new /source/src/lib/salad/mhash.h:402:39
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7f5d7a30dfa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa161ed in mh_i32ptr_new /source/src/lib/salad/mhash.h:403:32
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7f5d7a30dfa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa16264 in mh_i32ptr_new /source/src/lib/salad/mhash.h:406:23
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7f5d7a30dfa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa1628a in mh_i32ptr_new /source/src/lib/salad/mhash.h:408:22
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7f5d7a30dfa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

It was disabled in asan suppression file 'asan/lsan.supp' with block:

# test: box-tap/schema_mt.test.lua
# source: src/lib/salad/mhash.h
leak:mh_i32ptr_new

Steps to reproduce:
Login to dev1 test host

Start the docker container:

docker run --network=host -v $PWD:/source -w /source -ti registry.gitlab.com/tarantool/tarantool/testing/debian-buster:latest
Inside the docker container run:

mkdir /tnt ; cd /tnt/ ; rm -rf /tnt/*

CC=clang-8 CXX=clang++-8 cmake /source \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DENABLE_WERROR=ON \
        -DENABLE_ASAN=ON \
        -DENABLE_UB_SANITIZER=ON && make -j

cat >asan.patch <<EOF
diff --git a/asan/lsan.supp b/asan/lsan.supp
index 46b3001e9..927dc016f 100644
--- a/asan/lsan.supp
+++ b/asan/lsan.supp
@@ -44,6 +44,6 @@ leak:libc.so*
 
 # test: box-tap/schema_mt.test.lua
 # source: src/lib/salad/mhash.h
-leak:mh_i32ptr_new
+#leak:mh_i32ptr_new
 
 # test: sql-tap/gh2250-trigger-chain-limit.test.lua
 # source: src/lib/core/exception.cc
EOF
patch -p1 -i asan.patch

cd test

Create test 'box-tap/schema_mt_vinyl.test.lua' based on 'box-tap/schema_mt.test.lua':

#!/usr/bin/env tarantool
box.cfg{log="/tmp/tarantool_vinyl.log"}
local sp2 = box.schema.create_space('test2', {engine = 'vinyl'})
local sp2_pk = sp2:create_index('pk')
sp2:drop()
os.exit(0)

And run command:

ASAN_OPTIONS=heap_profile=0:unmap_shadow_on_exit=1:detect_invalid_pointer_pairs=1:symbolize=1:detect_leaks=1:dump_instruction_bytes=1:print_suppressions=0 LSAN_OPTIONS=suppressions=/source/asan/lsan.supp /source/test/test-run.py --builddir /tnt --vardir /tnt/test/var --force box-tap/schema_mt_vinyl.test.lua

It will produce errors:

Direct leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa161d8 in mh_i32ptr_new /source/src/lib/salad/mhash.h:402:39
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7fa4399c5fa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa161ed in mh_i32ptr_new /source/src/lib/salad/mhash.h:403:32
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7fa4399c5fa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa16264 in mh_i32ptr_new /source/src/lib/salad/mhash.h:406:23
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7fa4399c5fa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x524dfa in calloc (/tnt/src/tarantool+0x524dfa)
    #1 0xa1628a in mh_i32ptr_new /source/src/lib/salad/mhash.h:408:22
    #2 0x9d62d3 in cord_create /source/src/lib/core/fiber.c:1375:25
    #3 0x9d776f in cord_thread_func /source/src/lib/core/fiber.c:1454:2
    #4 0x7fa4399c5fa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

SUMMARY: AddressSanitizer: 1596 byte(s) leaked in 5 allocation(s).

Optional (but very desirable):

  • coredump
  • backtrace
  • netstat
@avtikhon avtikhon added qa Issues related to tests or testing subsystem asan labels Sep 25, 2020
@avtikhon avtikhon self-assigned this Sep 25, 2020
@avtikhon avtikhon added this to ON REVIEW in Quality Assurance Sep 25, 2020
@avtikhon avtikhon moved this from ON REVIEW to DONE in Quality Assurance Sep 25, 2020
@avtikhon avtikhon removed this from DONE in Quality Assurance Sep 25, 2020
@NickVolynkin NickVolynkin changed the title [1pt] asan: flaky memory leak on mh_i32ptr_new asan: flaky memory leak on mh_i32ptr_new Oct 24, 2022
@NickVolynkin NickVolynkin removed the qa Issues related to tests or testing subsystem label Oct 24, 2022
@TarantoolBot TarantoolBot removed the teamX label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants