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 fiber_cxx_invoke #5323

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

asan: flaky memory leak in fiber_cxx_invoke #5323

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

[001] Indirect leak of 16 byte(s) in 1 object(s) allocated from:
[001]     #0 0x52501f in realloc (/tnt/src/tarantool+0x52501f)
[001]     #1 0xf9bb06 in ev_realloc /source/third_party/libev/ev.c:1743:9
[001]     #2 0xf9bb06 in array_realloc /source/third_party/libev/ev.c:1975
[001]     #3 0xfac9bc in ev_async_start /source/third_party/libev/ev.c:4990:3
[001]     #4 0x9e1e2e in cbus_endpoint_create /source/src/lib/core/cbus.c:234:2
[001]     #5 0x81852c in vy_run_reader_f /source/src/box/vy_run.c:130:2
[001]     #6 0x55b25c in fiber_cxx_invoke(int (*)(__va_list_tag*), __va_list_tag*) /source/src/lib/core/fiber.h:788:10
[001]     #7 0x9d4eab in fiber_loop /source/src/lib/core/fiber.c:869:18
[001]     #8 0xfbe810 in coro_init /source/third_party/coro/coro.c:110:3
[001] 
[001] SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).

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

# test: vinyl/errinj.test.lua
# source: src/lib/core/fiber.h
leak:fiber_cxx_invoke

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..b3c175741 100644
--- a/asan/lsan.supp
+++ b/asan/lsan.supp
@@ -54,7 +52,7 @@ leak:Exception::operator new

 # test: vinyl/errinj.test.lua
 # source: src/lib/core/fiber.h
-leak:fiber_cxx_invoke
+#leak:fiber_cxx_invoke

 # test: vinyl/recover.test.lua
 # source: src/lib/core/fiber.c
EOF
patch -p1 -i asan.patch

cd test

Create test reproducer 'vinyl/gh-5323-errinj.test.lua' based on 'vinyl/errinj.test.lua':

test_run = require('test_run').new()
test_run:cmd("create server test with script='vinyl/low_quota.lua'")
test_run:cmd("start server test with args='1048576'")
test_run:cmd('switch test')

box.cfg{}
s = box.schema.space.create('test', {engine = 'vinyl'})
_ = s:create_index('i1', {parts = {1, 'unsigned'}})
s:drop()

test_run:cmd('switch default')
test_run:cmd("stop server test")
test_run:cmd("cleanup server test")

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-5323-errinj.test.lua

It will produce error on fiber_cxx_invoke().

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 fiber_cxx_invoke asan: flaky memory leak in fiber_cxx_invoke 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