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 in cord_costart_thread_func #5324

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

asan: flaky memory leak in cord_costart_thread_func #5324

avtikhon opened this issue Sep 23, 2020 · 0 comments
Labels
asan qa Issues related to tests or testing subsystem

Comments

@avtikhon
Copy link
Contributor

avtikhon commented Sep 23, 2020

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 leak:

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x52501f in realloc (/tnt/src/tarantool+0x52501f)
    #1 0xf9bb06 in ev_realloc /source/third_party/libev/ev.c:1743:9
    #2 0xf9bb06 in array_realloc /source/third_party/libev/ev.c:1975
    #3 0xf9b98e in ev_feed_event /source/third_party/libev/ev.c:2024:7
    #4 0xfade70 in pipecb /source/third_party/libev/ev.c:2575:13
    #5 0xf9ff12 in ev_invoke_pending /source/third_party/libev/ev.c:3349:11
    #6 0xfa1ced in ev_run /source/third_party/libev/ev.c:3752:7
    #7 0x9da9e8 in cord_costart_thread_func /source/src/lib/core/fiber.c:1663:3
    #8 0x9d82c2 in cord_thread_func /source/src/lib/core/fiber.c:1463:14
    #9 0x7f387767dfa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x52501f in realloc (/tnt/src/tarantool+0x52501f)
    #1 0xf9bb06 in ev_realloc /source/third_party/libev/ev.c:1743:9
    #2 0xf9bb06 in array_realloc /source/third_party/libev/ev.c:1975
    #3 0xf9b98e in ev_feed_event /source/third_party/libev/ev.c:2024:7
    #4 0xfae984 in fd_event_nocheck /source/third_party/libev/ev.c:2069:9
    #5 0xfae984 in fd_event /source/third_party/libev/ev.c:2081
    #6 0xfae984 in epoll_poll /source/third_party/libev/ev_epoll.c:211
    #7 0xfa0a7a in ev_run /source/third_party/libev/ev.c:3718:9
    #8 0x9da9e8 in cord_costart_thread_func /source/src/lib/core/fiber.c:1663:3
    #9 0x9d82c2 in cord_thread_func /source/src/lib/core/fiber.c:1463:14
    #10 0x7f387767dfa2 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7fa2)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 2 allocation(s).

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

# test: vinyl/recover.test.lua
# source: src/lib/core/fiber.c
leak:cord_costart_thread_func

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..6f0451d2e 100644
--- a/asan/lsan.supp
+++ b/asan/lsan.supp
@@ -58,4 +58,4 @@ leak:fiber_cxx_invoke
 
 # test: vinyl/recover.test.lua
 # source: src/lib/core/fiber.c
-leak:cord_costart_thread_func
+#leak:cord_costart_thread_func
EOF
patch -p1 -i asan.patch

cd test

Create test reproducer 'vinyl/gh-5324-recover.test.lua' based on 'vinyl/recover.test.lua':

box.cfg{}
s = box.schema.space.create('test', {engine = 'vinyl'})
_ = s:create_index('primary')
s:insert{1, 'test'}
box.snapshot()
os.exit()

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 vinyl/gh-5324-recover.test.lua

It will produce the issue.

Optional (but very desirable):

  • coredump
  • backtrace
  • netstat
@avtikhon avtikhon added qa Issues related to tests or testing subsystem asan labels Sep 23, 2020
@avtikhon avtikhon self-assigned this Sep 23, 2020
@avtikhon avtikhon added this to ON REVIEW in Quality Assurance Sep 23, 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 in cord_costart_thread_func asan: flaky memory leak in cord_costart_thread_func Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asan qa Issues related to tests or testing subsystem
Projects
None yet
Development

No branches or pull requests

1 participant