Skip to content

Commit 4d69526

Browse files
bhalevyavikivity
authored andcommitted
test: closeable: allocate variables accessed by continuations using do_with
Fixes failures in debug mode: ``` $ build/debug/tests/unit/closeable_test -l all -t deferred_close_test WARNING: debug mode. Not for benchmarking or production random-seed=3064133628 Running 1 test case... Entering test module "../../tests/unit/closeable_test.cc" ../../tests/unit/closeable_test.cc(0): Entering test case "deferred_close_test" ../../src/testing/seastar_test.cc(43): info: check true has passed ==9449==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases! terminate called after throwing an instance of 'seastar::broken_promise' what(): broken promise ==9449==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fbf1f49f000; bottom 0x7fbf40971000; size: 0xffffffffdeb2e000 (-558702592) False positive error reports may follow For details see google/sanitizers#189 ================================================================= ==9449==AddressSanitizer CHECK failed: ../../../../libsanitizer/asan/asan_thread.cpp:356 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0) #0 0x7fbf45f39d0b (/lib64/libasan.so.6+0xb3d0b) #1 0x7fbf45f57d4e (/lib64/libasan.so.6+0xd1d4e) #2 0x7fbf45f3e724 (/lib64/libasan.so.6+0xb8724) #3 0x7fbf45eb3e5b (/lib64/libasan.so.6+0x2de5b) #4 0x7fbf45eb51e8 (/lib64/libasan.so.6+0x2f1e8) #5 0x7fbf45eb7694 (/lib64/libasan.so.6+0x31694) #6 0x7fbf45f39398 (/lib64/libasan.so.6+0xb3398) #7 0x7fbf45f3a00b in __asan_report_load8 (/lib64/libasan.so.6+0xb400b) #8 0xfe6d52 in bool __gnu_cxx::operator!=<dl_phdr_info*, std::vector<dl_phdr_info, std::allocator<dl_phdr_info> > >(__gnu_cxx::__normal_iterator<dl_phdr_info*, std::vector<dl_phdr_info, std::allocator<dl_phdr_info> > > const&, __gnu_cxx::__normal_iterator<dl_phdr_info*, std::vector<dl_phdr_info, std::allocator<dl_phdr_info> > > const&) /usr/include/c++/10/bits/stl_iterator.h:1116 #9 0xfe615c in dl_iterate_phdr ../../src/core/exception_hacks.cc:121 #10 0x7fbf44bd1810 in _Unwind_Find_FDE (/lib64/libgcc_s.so.1+0x13810) #11 0x7fbf44bcd897 (/lib64/libgcc_s.so.1+0xf897) #12 0x7fbf44bcea5f (/lib64/libgcc_s.so.1+0x10a5f) #13 0x7fbf44bcefd8 in _Unwind_RaiseException (/lib64/libgcc_s.so.1+0x10fd8) #14 0xfe6281 in _Unwind_RaiseException ../../src/core/exception_hacks.cc:148 scylladb#15 0x7fbf457364bb in __cxa_throw (/lib64/libstdc++.so.6+0xaa4bb) scylladb#16 0x7fbf45e10a21 (/lib64/libboost_unit_test_framework.so.1.73.0+0x1aa21) scylladb#17 0x7fbf45e20fe0 in boost::execution_monitor::execute(boost::function<int ()> const&) (/lib64/libboost_unit_test_framework.so.1.73.0+0x2afe0) scylladb#18 0x7fbf45e21094 in boost::execution_monitor::vexecute(boost::function<void ()> const&) (/lib64/libboost_unit_test_framework.so.1.73.0+0x2b094) scylladb#19 0x7fbf45e43921 in boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) (/lib64/libboost_unit_test_framework.so.1.73.0+0x4d921) scylladb#20 0x7fbf45e5eae1 (/lib64/libboost_unit_test_framework.so.1.73.0+0x68ae1) scylladb#21 0x7fbf45e5ed31 (/lib64/libboost_unit_test_framework.so.1.73.0+0x68d31) scylladb#22 0x7fbf45e2e547 in boost::unit_test::framework::run(unsigned long, bool) (/lib64/libboost_unit_test_framework.so.1.73.0+0x38547) scylladb#23 0x7fbf45e43618 in boost::unit_test::unit_test_main(bool (*)(), int, char**) (/lib64/libboost_unit_test_framework.so.1.73.0+0x4d618) scylladb#24 0x44798d in seastar::testing::entry_point(int, char**) ../../src/testing/entry_point.cc:77 scylladb#25 0x4134b5 in main ../../include/seastar/testing/seastar_test.hh:65 scylladb#26 0x7fbf44a1b1e1 in __libc_start_main (/lib64/libc.so.6+0x281e1) scylladb#27 0x4133dd in _start (/home/bhalevy/dev/seastar/build/debug/tests/unit/closeable_test+0x4133dd) ``` Signed-off-by: Benny Halevy <bhalevy@scylladb.com> Message-Id: <20210406100911.12278-1-bhalevy@scylladb.com>
1 parent 9900b2e commit 4d69526

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/unit/closeable_test.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
using namespace seastar;
3030

3131
SEASTAR_TEST_CASE(deferred_close_test) {
32-
int count = 0;
33-
int expected = 42;
34-
gate g;
35-
32+
return do_with(gate(), 0, 42, [] (gate& g, int& count, int& expected) {
3633
return async([&] {
3734
auto close_gate = deferred_close(g);
3835

@@ -47,13 +44,11 @@ SEASTAR_TEST_CASE(deferred_close_test) {
4744
BOOST_REQUIRE(g.is_closed());
4845
BOOST_REQUIRE_EQUAL(count, expected);
4946
});
47+
});
5048
}
5149

5250
SEASTAR_TEST_CASE(close_now_test) {
53-
int count = 0;
54-
int expected = 42;
55-
gate g;
56-
51+
return do_with(gate(), 0, 42, [] (gate& g, int& count, int& expected) {
5752
return async([&] {
5853
auto close_gate = deferred_close(g);
5954

@@ -68,6 +63,7 @@ SEASTAR_TEST_CASE(close_now_test) {
6863
BOOST_REQUIRE_EQUAL(count, expected);
6964
// gate must not be double-closed.
7065
});
66+
});
7167
}
7268

7369
namespace {
@@ -84,19 +80,18 @@ struct count_stops {
8480
} // anonymous namespace
8581

8682
SEASTAR_TEST_CASE(deferred_stop_test) {
87-
count_stops cs;
88-
83+
return do_with(count_stops(), [] (count_stops& cs) {
8984
return async([&] {
9085
auto stop_counting = deferred_stop(cs);
9186
}).then([&] {
9287
// cs.stop() should be called when stop_counting is destroyed
9388
BOOST_REQUIRE_EQUAL(cs.stopped, 1);
9489
});
90+
});
9591
}
9692

9793
SEASTAR_TEST_CASE(stop_now_test) {
98-
count_stops cs;
99-
94+
return do_with(count_stops(), [] (count_stops& cs) {
10095
return async([&] {
10196
auto stop_counting = deferred_stop(cs);
10297

@@ -108,4 +103,5 @@ SEASTAR_TEST_CASE(stop_now_test) {
108103
// cs.stop() should be called exactly once
109104
BOOST_REQUIRE_EQUAL(cs.stopped, 1);
110105
});
106+
});
111107
}

0 commit comments

Comments
 (0)