You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some tests in ep_testsuite_dcp spawn a std::thread for running a DCP
client loop that opens DCP producer, issues a StreamRequest and listens
for data.
The problematic part here is in the StreamRequest. The Producer's
stream-map is type folly::AtomicHashArray<> that maps vbid->streams.
That folly type uses a few thread locals internally that end up storing
references to memory that is allocated in the bucket arena in the
EPE::stream_req path. Then std::thread is destroyed outside any bucket
context causing a mem track mismatch at thread's TSD release.
Eg:
% env CB_ARENA_MALLOC_VERIFY_DEALLOC_CLIENT=1 lldb -- ./ep_testsuite_dcp "-E" "ep" "-v" "-e" "compression_mode=active;dbname=./ep_testsuite_dcp.value_eviction.comp_active.db" -C 29
..
Running [29/91]: test producer keep stream open...===ERROR===: JeArenaMalloc deallocation mismatch
Memory freed by client:100 domain:None which is assigned arena:0, but memory was previously allocated from arena:2 (client-specific arena).
Allocation address:0x103dcda40 size:24
..
Process 90807 stopped
* thread #43, name = 'dcp_thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x185e46ae4)
frame #0: 0x0000000185e46ae4 libsystem_c.dylib` __abort + 168
libsystem_c.dylib`:
-> 0x185e46ae4 <+168>: brk #0x1
libsystem_c.dylib`abort_report_np:
0x185e46ae8 <+0>: pacibsp
0x185e46aec <+4>: sub sp, sp, #0x30
0x185e46af0 <+8>: stp x20, x19, [sp, #0x10]
Target 0: (ep_testsuite_dcp) stopped.
(lldb) bt
* thread #43, name = 'dcp_thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x185e46ae4)
* frame #0: 0x0000000185e46ae4 libsystem_c.dylib` __abort + 168
frame #1: 0x0000000185e46a3c libsystem_c.dylib` abort + 192
frame #2: 0x00000001001d8808 ep_testsuite_dcp` cb::verifyMemDeallocatedByCorrectClient(client=0x0000000171696c78, ptr=0x0000000103dcda40, size=24) + 536 at je_arena_malloc.cc:247
frame #3: 0x00000001001d8898 ep_testsuite_dcp` cb::_JEArenaMalloc<cb::JEArenaSimpleTracker>::sized_free(ptr=0x0000000103dcda40, size=24) + 84 at je_arena_malloc.cc:442
frame #4: 0x00000001000d6dc0 ep_testsuite_dcp` cb::_ArenaMalloc<cb::_JEArenaMalloc<cb::JEArenaSimpleTracker>>::sized_free(ptr=0x0000000103dcda40, size=24) + 32 at cb_arena_malloc.h:273
frame #5: 0x00000001000d6d8c ep_testsuite_dcp` cb_sized_free(ptr=0x0000000103dcda40, size=24) + 44 at cb_malloc_arena.cc:75
frame #6: 0x00000001000d7398 ep_testsuite_dcp` operator delete(ptr=0x0000000103dcda40, size=24) + 32 at global_new_replacement.cc:146
frame #7: 0x000000010081f534 ep_testsuite_dcp` void folly::threadlocal_detail::ElementWrapper::set<folly::ThreadCachedInt<unsigned long long, unsigned long long>::IntCache*>(this=0x0000000171696d33, pt=0x0000000103dcda40, (null)=THIS_THREAD)::'lambda'(void*, folly::TLPDestructionMode)::operator()(void*, folly::TLPDestructionMode) const + 68 at ThreadLocalDetail.h:138
frame #8: 0x000000010081f4e4 ep_testsuite_dcp` void folly::threadlocal_detail::ElementWrapper::set<folly::ThreadCachedInt<unsigned long long, unsigned long long>::IntCache*>(folly::ThreadCachedInt<unsigned long long, unsigned long long>::IntCache*)::'lambda'(void*, folly::TLPDestructionMode)::__invoke(pt=0x0000000103dcda40, (null)=THIS_THREAD) + 36 at ThreadLocalDetail.h:137
frame #9: 0x0000000100168e90 ep_testsuite_dcp` folly::threadlocal_detail::ElementWrapper::dispose(this=0x000000011f7053c8, mode=THIS_THREAD) + 324 at ThreadLocalDetail.h:114
frame #10: 0x0000000100cd0758 ep_testsuite_dcp` folly::threadlocal_detail::StaticMetaBase::onThreadExit(ptr=0x0000000103dd1800) + 404 at ThreadLocalDetail.cpp:153
frame #11: 0x0000000185f37870 libsystem_pthread.dylib` _pthread_tsd_cleanup + 488
frame #12: 0x0000000185f3a684 libsystem_pthread.dylib` _pthread_exit + 84
frame #13: 0x0000000185f39fa0 libsystem_pthread.dylib` _pthread_start + 148
Fix by executing DcpOpen+StreamRequest in the main test thread. All
memcached/bucket resources are released before the main thread shuts down.
Notes:
- That is a test-only issue, no production bug addressed here
- Patch verified locally by
https://review.couchbase.org/c/platform/+/234973, which is being
submitted after all related failures are fixed
Change-Id: Ida20abef00daddb8da4d65305316eba7baccaec7
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/235361
Tested-by: Build Bot <[email protected]>
Well-Formed: Restriction Checker
Reviewed-by: Jim Walker <[email protected]>
0 commit comments