From 20496ed9a89dbb52001d12a338d494be20ff7ba3 Mon Sep 17 00:00:00 2001 From: Asias He Date: Fri, 22 Jan 2016 15:05:55 +0800 Subject: [PATCH] tests: Stop gossip during shutdown in cql_test_env Fixes the heap-use-after-free error in build/debug/tests/auth_test ==1415==ERROR: AddressSanitizer: heap-use-after-free on address 0x62200032cfa8 at pc 0x00000350701d bp 0x7fec96df8d40 sp 0x7fec96df8d30 READ of size 8 at 0x62200032cfa8 thread T1 #0 0x350701c in _ZZN3gms8gossiper3runEvENKUlOT_E0_clI6futureIJEEEEDaS2_ (/home/penberg/scylla/build/debug/tests/auth_test_g+0x350701c) #1 0x35795b1 in apply, future<> > /home/penberg/scylla/seastar/core/future.hh:1203 #2 0x369103d in _ZZN6futureIJEE12then_wrappedIZN3gms8gossiper3runEvEUlOT_E0_S0_EET0_S5_ENUlS5_E_clI12future_stateIJEEEEDaS5_ (/home/penberg/scylla/build/debug/tests/auth_test_g+0x369103d) #3 0x369182a in run /home/penberg/scylla/seastar/core/future.hh:399 #4 0x435f24 in reactor::run_tasks(circular_buffer >, std::allocator > > >&) core/reactor.cc:1368 #5 0x43a44f in reactor::run() core/reactor.cc:1672 #6 0x952e4b in app_template::run_deprecated(int, char**, std::function&&) core/app-template.cc:123 #7 0x58dc79d in test_runner::start(int, char**)::{lambda()#1}::operator()() (/home/penberg/scylla/build/debug/tests/auth_test_g+0x58dc79d) #8 0x58e6cd6 in _M_invoke /usr/include/c++/5.3.1/functional:1871 #9 0x688639 in std::function::operator()() const /usr/include/c++/5.3.1/functional:2271 #10 0x8d939c in posix_thread::start_routine(void*) core/posix.cc:51 #11 0x7feca02a4609 in start_thread (/lib64/libpthread.so.0+0x7609) #12 0x7fec9ffdea4c in clone (/lib64/libc.so.6+0x102a4c) 0x62200032cfa8 is located 5800 bytes inside of 5808-byte region [0x62200032b900,0x62200032cfb0) freed by thread T1 here: #0 0x7feca4f76472 in operator delete(void*, unsigned long) (/lib64/libasan.so.2+0x9a472) #1 0x3740772 in gms::gossiper::~gossiper() (/home/penberg/scylla/build/debug/tests/auth_test_g+0x3740772) #2 0x2588ba1 in shared_ptr::~shared_ptr() seastar/core/shared_ptr.hh:389 #3 0x4fc908c in seastar::sharded::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1}::~stop() (/home/penberg/scylla/build/debug/tests/auth_test_g+0x4fc908c) #4 0x4ff722a in future<> future<>::then::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1}, future<> >(seastar::sharded::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1}&&)::{lambda(seastar::sharded::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1})#1}::~then() (/home/penberg/scylla/build/debug/tests/auth_test_g+0x4ff722a) #5 0x509a28c in continuation future<>::then::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1}, future<> >(seastar::sharded::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1}&&)::{lambda(seastar::sharded::stop()::{lambda(unsigned int)#1}::operator()(unsigned int)::{lambda()#1}::operator()()::{lambda()#1})#1}>::~continuation() seastar/core/future.hh:395 #6 0x509a40d in continuation Message-Id: --- tests/cql_test_env.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/cql_test_env.cc b/tests/cql_test_env.cc index 68db7de5f3..557da1d9ab 100644 --- a/tests/cql_test_env.cc +++ b/tests/cql_test_env.cc @@ -320,6 +320,9 @@ public: virtual future<> stop() override { return seastar::async([this] { + // Started by storage_service::init_server() + gms::get_local_gossiper().stop_gossiping().get(); + _core_local.stop().get(); db::system_keyspace::deinit_local_cache().get();