Skip to content

Instantly share code, notes, and snippets.

@daverigby
Last active September 10, 2020 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daverigby/02526838ccfe6ddc64ea977e0018f485 to your computer and use it in GitHub Desktop.
Save daverigby/02526838ccfe6ddc64ea977e0018f485 to your computer and use it in GitHub Desktop.
  • Lambda t1 (lines 97-101):
(gdb) disas /s 0x00000000004cd7ce
Dump of assembler code for function ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const:
/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/io/async/test/ScopedEventBaseThreadTest.cpp:
97	  std::thread t1([&] {
   0x00000000004cd74c <+0>:	push   %rbp
   0x00000000004cd74d <+1>:	mov    %rsp,%rbp
   0x00000000004cd750 <+4>:	push   %rbx
   0x00000000004cd751 <+5>:	sub    $0x2b8,%rsp
   0x00000000004cd758 <+12>:	mov    %rdi,-0x2b8(%rbp)
   0x00000000004cd75f <+19>:	mov    %fs:0x28,%rax
   0x00000000004cd768 <+28>:	mov    %rax,-0x18(%rbp)
   0x00000000004cd76c <+32>:	xor    %eax,%eax
   0x00000000004cd76e <+34>:	mov    0x8(%rbp),%rax
   0x00000000004cd772 <+38>:	mov    %rax,%rdi
   0x00000000004cd775 <+41>:	callq  0x4ca6d0 <__tsan_func_entry@plt>

98	    ScopedEventBaseThread sebt;
   0x00000000004cd77a <+46>:	lea    -0x2a0(%rbp),%rax
   0x00000000004cd781 <+53>:	mov    %rax,%rdi
   0x00000000004cd784 <+56>:	callq  0x5deee6 <folly::ScopedEventBaseThread::ScopedEventBaseThread()>

99	    ex = &sebt;
   0x00000000004cd789 <+61>:	lea    -0x2a0(%rbp),%rdx
   0x00000000004cd790 <+68>:	lea    -0x2a8(%rbp),%rax
   0x00000000004cd797 <+75>:	mov    %rdx,%rsi
   0x00000000004cd79a <+78>:	mov    %rax,%rdi
   0x00000000004cd79d <+81>:	callq  0x4d9b56 <folly::Executor::KeepAlive<folly::Executor>::KeepAlive(folly::Executor*)>
   0x00000000004cd7a2 <+86>:	mov    -0x2b8(%rbp),%rax
   0x00000000004cd7a9 <+93>:	mov    %rax,%rdi
   0x00000000004cd7ac <+96>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cd7b1 <+101>:	mov    -0x2b8(%rbp),%rax
   0x00000000004cd7b8 <+108>:	mov    (%rax),%rax
   0x00000000004cd7bb <+111>:	lea    -0x2a8(%rbp),%rdx
   0x00000000004cd7c2 <+118>:	mov    %rdx,%rsi
   0x00000000004cd7c5 <+121>:	mov    %rax,%rdi
   0x00000000004cd7c8 <+124>:	callq  0x4d9c02 <folly::Executor::KeepAlive<folly::Executor>::operator=(folly::Executor::KeepAlive<folly::Executor>&&)>
   0x00000000004cd7cd <+129>:	lea    -0x2a8(%rbp),%rax
   0x00000000004cd7d4 <+136>:	mov    %rax,%rdi
   0x00000000004cd7d7 <+139>:	callq  0x4d88cc <folly::Executor::KeepAlive<folly::Executor>::~KeepAlive()>
   0x00000000004cd7dc <+144>:	mov    -0x2b8(%rbp),%rax
   0x00000000004cd7e3 <+151>:	add    $0x8,%rax

100	    started.post();
   0x00000000004cd7e7 <+155>:	mov    %rax,%rdi
   0x00000000004cd7ea <+158>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cd7ef <+163>:	mov    -0x2b8(%rbp),%rax
   0x00000000004cd7f6 <+170>:	mov    0x8(%rax),%rax
   0x00000000004cd7fa <+174>:	mov    %rax,%rdi
   0x00000000004cd7fd <+177>:	callq  0x4d9190 <folly::Baton<true, std::atomic>::post()>

98	    ScopedEventBaseThread sebt;
   0x00000000004cd802 <+182>:	lea    -0x2a0(%rbp),%rax
   0x00000000004cd809 <+189>:	mov    %rax,%rdi
   0x00000000004cd80c <+192>:	callq  0x5df9fc <folly::ScopedEventBaseThread::~ScopedEventBaseThread()>
   0x00000000004cd811 <+197>:	callq  0x4c9d50 <__tsan_func_exit@plt>

101	  });
   0x00000000004cd816 <+202>:	nop
   0x00000000004cd817 <+203>:	mov    -0x18(%rbp),%rax
   0x00000000004cd81b <+207>:	xor    %fs:0x28,%rax
   0x00000000004cd824 <+216>:	je     0x4cd854 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+264>
   0x00000000004cd826 <+218>:	jmp    0x4cd84f <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+259>
   0x00000000004cd828 <+220>:	mov    %rax,%rbx

98	    ScopedEventBaseThread sebt;
   0x00000000004cd82b <+223>:	lea    -0x2a0(%rbp),%rax
   0x00000000004cd832 <+230>:	mov    %rax,%rdi
   0x00000000004cd835 <+233>:	callq  0x5df9fc <folly::ScopedEventBaseThread::~ScopedEventBaseThread()>
   0x00000000004cd83a <+238>:	jmp    0x4cd83f <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+243>
   0x00000000004cd83c <+240>:	mov    %rax,%rbx
   0x00000000004cd83f <+243>:	callq  0x4c9d50 <__tsan_func_exit@plt>
   0x00000000004cd844 <+248>:	mov    %rbx,%rax
   0x00000000004cd847 <+251>:	mov    %rax,%rdi
   0x00000000004cd84a <+254>:	callq  0x4c9d00 <_Unwind_Resume@plt>

101	  });
   0x00000000004cd84f <+259>:	callq  0x4c95a0 <__stack_chk_fail@plt>
   0x00000000004cd854 <+264>:	add    $0x2b8,%rsp
   0x00000000004cd85b <+271>:	pop    %rbx
   0x00000000004cd85c <+272>:	pop    %rbp
   0x00000000004cd85d <+273>:	retq   
  • Lambda t2 (lines 103-108):
(gdb) disas /s 0x00000000004cd8ce
Dump of assembler code for function ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const:
/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/io/async/test/ScopedEventBaseThreadTest.cpp:
103	  std::thread t2([&] {
   0x00000000004cd8ce <+0>:	push   %rbp
   0x00000000004cd8cf <+1>:	mov    %rsp,%rbp
   0x00000000004cd8d2 <+4>:	push   %r13
   0x00000000004cd8d4 <+6>:	push   %r12
   0x00000000004cd8d6 <+8>:	push   %rbx
   0x00000000004cd8d7 <+9>:	sub    $0x88,%rsp
   0x00000000004cd8de <+16>:	mov    %rdi,-0x98(%rbp)
   0x00000000004cd8e5 <+23>:	mov    %fs:0x28,%rax
   0x00000000004cd8ee <+32>:	mov    %rax,-0x28(%rbp)
   0x00000000004cd8f2 <+36>:	xor    %eax,%eax
   0x00000000004cd8f4 <+38>:	mov    0x8(%rbp),%rax
   0x00000000004cd8f8 <+42>:	mov    %rax,%rdi
   0x00000000004cd8fb <+45>:	callq  0x4ca6d0 <__tsan_func_entry@plt>
   0x00000000004cd900 <+50>:	mov    -0x98(%rbp),%rax

104	    started.wait();
   0x00000000004cd907 <+57>:	mov    %rax,%rdi
   0x00000000004cd90a <+60>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cd90f <+65>:	mov    -0x98(%rbp),%rax
   0x00000000004cd916 <+72>:	mov    (%rax),%rbx

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
61	    return {};
   0x00000000004cd919 <+75>:	lea    -0x40(%rbp),%rax
   0x00000000004cd91d <+79>:	mov    %rax,%rdi
   0x00000000004cd920 <+82>:	callq  0x4cab20 <__tsan_write8@plt>
   0x00000000004cd925 <+87>:	movq   $0x0,-0x40(%rbp)
   0x00000000004cd92d <+95>:	lea    -0x40(%rbp),%rax
   0x00000000004cd931 <+99>:	add    $0x8,%rax
   0x00000000004cd935 <+103>:	mov    %rax,%rdi
   0x00000000004cd938 <+106>:	callq  0x4ca690 <__tsan_write1@plt>
   0x00000000004cd93d <+111>:	movb   $0x0,-0x38(%rbp)
   0x00000000004cd941 <+115>:	lea    -0x40(%rbp),%rax
   0x00000000004cd945 <+119>:	mov    %rax,%rdi
   0x00000000004cd948 <+122>:	callq  0x4d943c <folly::WaitOptions::WaitOptions()>
   0x00000000004cd94d <+127>:	lea    -0x40(%rbp),%rax
   0x00000000004cd951 <+131>:	mov    %rax,%rdi
   0x00000000004cd954 <+134>:	callq  0x4c99a0 <__tsan_read16@plt>
   0x00000000004cd959 <+139>:	mov    -0x40(%rbp),%rax
   0x00000000004cd95d <+143>:	mov    -0x38(%rbp),%rdx
   0x00000000004cd961 <+147>:	mov    %rax,%r12
   0x00000000004cd964 <+150>:	mov    %rdx,%r13

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/io/async/test/ScopedEventBaseThreadTest.cpp:
104	    started.wait();
   0x00000000004cd967 <+153>:	lea    -0x40(%rbp),%rax
   0x00000000004cd96b <+157>:	mov    %rax,%rdi
   0x00000000004cd96e <+160>:	callq  0x4c9070 <__tsan_write16@plt>
   0x00000000004cd973 <+165>:	mov    %r12,-0x40(%rbp)
   0x00000000004cd977 <+169>:	mov    %r13,-0x38(%rbp)
   0x00000000004cd97b <+173>:	mov    %rbx,-0x60(%rbp)
   0x00000000004cd97f <+177>:	mov    -0x60(%rbp),%rax
   0x00000000004cd983 <+181>:	mov    %rax,-0x58(%rbp)
   0x00000000004cd987 <+185>:	mov    -0x58(%rbp),%rax
   0x00000000004cd98b <+189>:	mov    %rax,-0x50(%rbp)

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
90	    auto s = state_.load(std::memory_order_acquire);
   0x00000000004cd98f <+193>:	mov    -0x50(%rbp),%rax
   0x00000000004cd993 <+197>:	mov    %rax,-0x48(%rbp)
   0x00000000004cd997 <+201>:	movl   $0x2,-0x8c(%rbp)

/usr/include/c++/9/bits/atomic_base.h:
415		memory_order __b = __m & __memory_order_mask;
   0x00000000004cd9a1 <+211>:	mov    -0x8c(%rbp),%eax
   0x00000000004cd9a7 <+217>:	mov    $0xffff,%esi
   0x00000000004cd9ac <+222>:	mov    %eax,%edi
   0x00000000004cd9ae <+224>:	callq  0x4d23a6 <std::operator&(std::memory_order, std::__memory_order_modifier)>
   0x00000000004cd9b3 <+229>:	mov    %eax,-0x88(%rbp)

416		__glibcxx_assert(__b != memory_order_release);
417		__glibcxx_assert(__b != memory_order_acq_rel);
418	
419		return __atomic_load_n(&_M_i, int(__m));
   0x00000000004cd9b9 <+235>:	mov    -0x8c(%rbp),%edx
   0x00000000004cd9bf <+241>:	mov    -0x48(%rbp),%rax
   0x00000000004cd9c3 <+245>:	mov    %edx,%esi
   0x00000000004cd9c5 <+247>:	mov    %rax,%rdi
   0x00000000004cd9c8 <+250>:	callq  0x4c9740 <__tsan_atomic32_load@plt>
   0x00000000004cd9cd <+255>:	nop

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
90	    auto s = state_.load(std::memory_order_acquire);
   0x00000000004cd9ce <+256>:	mov    %eax,-0x84(%rbp)

91	    assert(s == INIT || s == EARLY_DELIVERY);
   0x00000000004cd9d4 <+262>:	cmpl   $0x0,-0x84(%rbp)
   0x00000000004cd9db <+269>:	je     0x4cda05 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+311>
   0x00000000004cd9dd <+271>:	cmpl   $0x1,-0x84(%rbp)
   0x00000000004cd9e4 <+278>:	je     0x4cda05 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+311>
   0x00000000004cd9e6 <+280>:	lea    0x3505e3(%rip),%rcx        # 0x81dfd0
   0x00000000004cd9ed <+287>:	mov    $0x5b,%edx
   0x00000000004cd9f2 <+292>:	lea    0x35063f(%rip),%rsi        # 0x81e038
   0x00000000004cd9f9 <+299>:	lea    0x3506b0(%rip),%rdi        # 0x81e0b0
   0x00000000004cda00 <+306>:	callq  0x4c9240 <__assert_fail@plt>

92	    return LIKELY(s == EARLY_DELIVERY);
   0x00000000004cda05 <+311>:	cmpl   $0x1,-0x84(%rbp)
   0x00000000004cda0c <+318>:	sete   %al
   0x00000000004cda0f <+321>:	movzbl %al,%eax
   0x00000000004cda12 <+324>:	test   %rax,%rax
   0x00000000004cda15 <+327>:	setne  %al

179	  }
180	
181	  /// Similar to wait, but doesn't block the thread if it hasn't been posted.
182	  ///
183	  /// try_wait has the following semantics:
184	  /// - It is ok to call try_wait any number times on the same baton until
185	  ///   try_wait reports that the baton has been posted.
186	  /// - It is ok to call timed_wait or wait on the same baton if try_wait
187	  ///   reports that baton hasn't been posted.
188	  /// - If try_wait indicates that the baton has been posted, it is invalid to
189	  ///   call wait, try_wait or timed_wait on the same baton without resetting
190	  ///
191	  /// @return       true if baton has been posted, false othewise
192	  FOLLY_ALWAYS_INLINE bool try_wait() const noexcept {
193	    return ready();
   0x00000000004cda18 <+330>:	nop

173	    if (try_wait()) {
   0x00000000004cda19 <+331>:	test   %al,%al
   0x00000000004cda1b <+333>:	jne    0x4cda42 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+372>

174	      return;
175	    }
176	
177	    auto const deadline = std::chrono::steady_clock::time_point::max();
   0x00000000004cda1d <+335>:	movabs $0x7fffffffffffffff,%rax
   0x00000000004cda27 <+345>:	mov    %rax,-0x68(%rbp)

178	    tryWaitSlow(deadline, opt);
   0x00000000004cda2b <+349>:	lea    -0x40(%rbp),%rdx
   0x00000000004cda2f <+353>:	lea    -0x68(%rbp),%rcx
   0x00000000004cda33 <+357>:	mov    -0x60(%rbp),%rax
   0x00000000004cda37 <+361>:	mov    %rcx,%rsi
   0x00000000004cda3a <+364>:	mov    %rax,%rdi
   0x00000000004cda3d <+367>:	callq  0x4dc7e4 <folly::Baton<true, std::atomic>::tryWaitSlow<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, folly::WaitOptions const&)>
   0x00000000004cda42 <+372>:	mov    -0x98(%rbp),%rax
   0x00000000004cda49 <+379>:	add    $0x8,%rax

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/io/async/test/ScopedEventBaseThreadTest.cpp:
105	    p.getSemiFuture().via(ex).thenValue([&, ex](auto&&) { done.post(); });
   0x00000000004cda4d <+383>:	mov    %rax,%rdi
   0x00000000004cda50 <+386>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cda55 <+391>:	mov    -0x98(%rbp),%rax
   0x00000000004cda5c <+398>:	mov    0x8(%rax),%rdx
   0x00000000004cda60 <+402>:	lea    -0x80(%rbp),%rax
   0x00000000004cda64 <+406>:	mov    %rdx,%rsi
   0x00000000004cda67 <+409>:	mov    %rax,%rdi
   0x00000000004cda6a <+412>:	callq  0x4d9e0a <folly::Promise<folly::Unit>::getSemiFuture()>
   0x00000000004cda6f <+417>:	mov    -0x98(%rbp),%rax
   0x00000000004cda76 <+424>:	add    $0x10,%rax
   0x00000000004cda7a <+428>:	mov    %rax,%rdi
   0x00000000004cda7d <+431>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cda82 <+436>:	mov    -0x98(%rbp),%rax
   0x00000000004cda89 <+443>:	mov    0x10(%rax),%rdx
   0x00000000004cda8d <+447>:	lea    -0x78(%rbp),%rax
   0x00000000004cda91 <+451>:	mov    %rdx,%rsi
   0x00000000004cda94 <+454>:	mov    %rax,%rdi
   0x00000000004cda97 <+457>:	callq  0x4d9e9a <folly::Executor::KeepAlive<folly::Executor>::KeepAlive(folly::Executor::KeepAlive<folly::Executor> const&)>
   0x00000000004cda9c <+462>:	lea    -0x70(%rbp),%rax
   0x00000000004cdaa0 <+466>:	lea    -0x78(%rbp),%rdx
   0x00000000004cdaa4 <+470>:	lea    -0x80(%rbp),%rcx
   0x00000000004cdaa8 <+474>:	mov    %rcx,%rsi
   0x00000000004cdaab <+477>:	mov    %rax,%rdi
   0x00000000004cdaae <+480>:	callq  0x4d9f00 <folly::SemiFuture<folly::Unit>::via(folly::Executor::KeepAlive<folly::Executor>) &&>
   0x00000000004cdab3 <+485>:	mov    -0x98(%rbp),%rax
   0x00000000004cdaba <+492>:	add    $0x10,%rax
   0x00000000004cdabe <+496>:	mov    %rax,%rdi
   0x00000000004cdac1 <+499>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cdac6 <+504>:	mov    -0x98(%rbp),%rax
   0x00000000004cdacd <+511>:	mov    0x10(%rax),%rdx
   0x00000000004cdad1 <+515>:	lea    -0x40(%rbp),%rax
   0x00000000004cdad5 <+519>:	mov    %rdx,%rsi
   0x00000000004cdad8 <+522>:	mov    %rax,%rdi
   0x00000000004cdadb <+525>:	callq  0x4d9e9a <folly::Executor::KeepAlive<folly::Executor>::KeepAlive(folly::Executor::KeepAlive<folly::Executor> const&)>
   0x00000000004cdae0 <+530>:	mov    -0x98(%rbp),%rax
   0x00000000004cdae7 <+537>:	add    $0x18,%rax
   0x00000000004cdaeb <+541>:	mov    %rax,%rdi
   0x00000000004cdaee <+544>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cdaf3 <+549>:	mov    -0x98(%rbp),%rax
   0x00000000004cdafa <+556>:	mov    0x18(%rax),%rbx
   0x00000000004cdafe <+560>:	lea    -0x40(%rbp),%rax
   0x00000000004cdb02 <+564>:	add    $0x8,%rax
   0x00000000004cdb06 <+568>:	mov    %rax,%rdi
   0x00000000004cdb09 <+571>:	callq  0x4cab20 <__tsan_write8@plt>
   0x00000000004cdb0e <+576>:	mov    %rbx,-0x38(%rbp)
   0x00000000004cdb12 <+580>:	lea    -0x68(%rbp),%rax
   0x00000000004cdb16 <+584>:	lea    -0x40(%rbp),%rdx
   0x00000000004cdb1a <+588>:	lea    -0x70(%rbp),%rcx
   0x00000000004cdb1e <+592>:	mov    %rcx,%rsi
   0x00000000004cdb21 <+595>:	mov    %rax,%rdi
   0x00000000004cdb24 <+598>:	callq  0x4ce934 <folly::Future<folly::Unit>::thenValue<ScopedEventBaseThreadTest_keepalive_Test::TestBody()::<lambda()>::<lambda(auto:53&&)> >(<unknown type in /home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/ScopedEventBaseThreadTest, CU 0x1ae, DIE 0x6ea34>)>
   0x00000000004cdb29 <+603>:	lea    -0x68(%rbp),%rax
   0x00000000004cdb2d <+607>:	mov    %rax,%rdi
   0x00000000004cdb30 <+610>:	callq  0x4d449c <folly::Future<folly::Unit>::~Future()>
   0x00000000004cdb35 <+615>:	lea    -0x40(%rbp),%rax
   0x00000000004cdb39 <+619>:	mov    %rax,%rdi
   0x00000000004cdb3c <+622>:	callq  0x4cd85e <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::<lambda(auto:53&&)>::~<lambda>(void)>
   0x00000000004cdb41 <+627>:	lea    -0x70(%rbp),%rax
   0x00000000004cdb45 <+631>:	mov    %rax,%rdi
   0x00000000004cdb48 <+634>:	callq  0x4d449c <folly::Future<folly::Unit>::~Future()>
   0x00000000004cdb4d <+639>:	lea    -0x78(%rbp),%rax
   0x00000000004cdb51 <+643>:	mov    %rax,%rdi
   0x00000000004cdb54 <+646>:	callq  0x4d88cc <folly::Executor::KeepAlive<folly::Executor>::~KeepAlive()>
   0x00000000004cdb59 <+651>:	lea    -0x80(%rbp),%rax
   0x00000000004cdb5d <+655>:	mov    %rax,%rdi
   0x00000000004cdb60 <+658>:	callq  0x4d710c <folly::SemiFuture<folly::Unit>::~SemiFuture()>
   0x00000000004cdb65 <+663>:	mov    -0x98(%rbp),%rax
   0x00000000004cdb6c <+670>:	add    $0x10,%rax
   0x00000000004cdb70 <+674>:	mov    %rax,%rdi
   0x00000000004cdb73 <+677>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cdb78 <+682>:	mov    -0x98(%rbp),%rax
   0x00000000004cdb7f <+689>:	mov    0x10(%rax),%rax

106	    ex.reset();
   0x00000000004cdb83 <+693>:	mov    %rax,%rdi
   0x00000000004cdb86 <+696>:	callq  0x4da0c0 <folly::Executor::KeepAlive<folly::Executor>::reset()>
   0x00000000004cdb8b <+701>:	mov    -0x98(%rbp),%rax
   0x00000000004cdb92 <+708>:	add    $0x20,%rax

107	    reset.post();
   0x00000000004cdb96 <+712>:	mov    %rax,%rdi
   0x00000000004cdb99 <+715>:	callq  0x4c8f70 <__tsan_read8@plt>
   0x00000000004cdb9e <+720>:	mov    -0x98(%rbp),%rax
   0x00000000004cdba5 <+727>:	mov    0x20(%rax),%rax
   0x00000000004cdba9 <+731>:	mov    %rax,%rdi
   0x00000000004cdbac <+734>:	callq  0x4d9190 <folly::Baton<true, std::atomic>::post()>
   0x00000000004cdbb1 <+739>:	callq  0x4c9d50 <__tsan_func_exit@plt>

108	  });
   0x00000000004cdbb6 <+744>:	nop
   0x00000000004cdbb7 <+745>:	mov    -0x28(%rbp),%rax
   0x00000000004cdbbb <+749>:	xor    %fs:0x28,%rax
   0x00000000004cdbc4 <+758>:	je     0x4cdc1a <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+844>
   0x00000000004cdbc6 <+760>:	jmp    0x4cdc15 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+839>
   0x00000000004cdbc8 <+762>:	mov    %rax,%rbx

105	    p.getSemiFuture().via(ex).thenValue([&, ex](auto&&) { done.post(); });
   0x00000000004cdbcb <+765>:	lea    -0x40(%rbp),%rax
   0x00000000004cdbcf <+769>:	mov    %rax,%rdi
   0x00000000004cdbd2 <+772>:	callq  0x4cd85e <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::<lambda(auto:53&&)>::~<lambda>(void)>
   0x00000000004cdbd7 <+777>:	lea    -0x70(%rbp),%rax
   0x00000000004cdbdb <+781>:	mov    %rax,%rdi
   0x00000000004cdbde <+784>:	callq  0x4d449c <folly::Future<folly::Unit>::~Future()>
   0x00000000004cdbe3 <+789>:	jmp    0x4cdbe8 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+794>
   0x00000000004cdbe5 <+791>:	mov    %rax,%rbx
   0x00000000004cdbe8 <+794>:	lea    -0x78(%rbp),%rax
   0x00000000004cdbec <+798>:	mov    %rax,%rdi
   0x00000000004cdbef <+801>:	callq  0x4d88cc <folly::Executor::KeepAlive<folly::Executor>::~KeepAlive()>
   0x00000000004cdbf4 <+806>:	lea    -0x80(%rbp),%rax
   0x00000000004cdbf8 <+810>:	mov    %rax,%rdi
   0x00000000004cdbfb <+813>:	callq  0x4d710c <folly::SemiFuture<folly::Unit>::~SemiFuture()>
   0x00000000004cdc00 <+818>:	jmp    0x4cdc05 <ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const+823>
   0x00000000004cdc02 <+820>:	mov    %rax,%rbx
   0x00000000004cdc05 <+823>:	callq  0x4c9d50 <__tsan_func_exit@plt>
   0x00000000004cdc0a <+828>:	mov    %rbx,%rax
   0x00000000004cdc0d <+831>:	mov    %rax,%rdi
   0x00000000004cdc10 <+834>:	callq  0x4c9d00 <_Unwind_Resume@plt>

108	  });
   0x00000000004cdc15 <+839>:	callq  0x4c95a0 <__stack_chk_fail@plt>
   0x00000000004cdc1a <+844>:	add    $0x88,%rsp
   0x00000000004cdc21 <+851>:	pop    %rbx
   0x00000000004cdc22 <+852>:	pop    %r12
   0x00000000004cdc24 <+854>:	pop    %r13
   0x00000000004cdc26 <+856>:	pop    %rbp
   0x00000000004cdc27 <+857>:	retq 
  • folly::Baton<>::post()
(gdb) disas /s 0x00000000004d9190
Dump of assembler code for function folly::Baton<true, std::atomic>::post():
/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
125	  void post() noexcept {
   0x00000000004d9190 <+0>:	push   %rbp
   0x00000000004d9191 <+1>:	mov    %rsp,%rbp
   0x00000000004d9194 <+4>:	push   %rbx
   0x00000000004d9195 <+5>:	sub    $0x68,%rsp
   0x00000000004d9199 <+9>:	mov    %rdi,-0x68(%rbp)
   0x00000000004d919d <+13>:	mov    %fs:0x28,%rax
   0x00000000004d91a6 <+22>:	mov    %rax,-0x18(%rbp)
   0x00000000004d91aa <+26>:	xor    %eax,%eax
   0x00000000004d91ac <+28>:	mov    0x8(%rbp),%rax
   0x00000000004d91b0 <+32>:	mov    %rax,%rdi
   0x00000000004d91b3 <+35>:	callq  0x4ca6d0 <__tsan_func_entry@plt>

126	    if (!MayBlock) {
127	      /// Spin-only version
128	      ///
129	      assert(
130	          ((1 << state_.load(std::memory_order_relaxed)) &
131	           ((1 << INIT) | (1 << EARLY_DELIVERY))) != 0);
132	      state_.store(EARLY_DELIVERY, std::memory_order_release);
133	      return;
134	    }
135	
136	    /// May-block versions
137	    ///
138	    uint32_t before = state_.load(std::memory_order_acquire);
   0x00000000004d91b8 <+40>:	mov    -0x68(%rbp),%rax
   0x00000000004d91bc <+44>:	mov    %rax,-0x30(%rbp)
   0x00000000004d91c0 <+48>:	movl   $0x2,-0x58(%rbp)

/usr/include/c++/9/bits/atomic_base.h:
415		memory_order __b = __m & __memory_order_mask;
   0x00000000004d91c7 <+55>:	mov    -0x58(%rbp),%eax
   0x00000000004d91ca <+58>:	mov    $0xffff,%esi
   0x00000000004d91cf <+63>:	mov    %eax,%edi
   0x00000000004d91d1 <+65>:	callq  0x4d23a6 <std::operator&(std::memory_order, std::__memory_order_modifier)>
   0x00000000004d91d6 <+70>:	mov    %eax,-0x54(%rbp)

416		__glibcxx_assert(__b != memory_order_release);
417		__glibcxx_assert(__b != memory_order_acq_rel);
418	
419		return __atomic_load_n(&_M_i, int(__m));
   0x00000000004d91d9 <+73>:	mov    -0x58(%rbp),%edx
   0x00000000004d91dc <+76>:	mov    -0x30(%rbp),%rax
   0x00000000004d91e0 <+80>:	mov    %edx,%esi
   0x00000000004d91e2 <+82>:	mov    %rax,%rdi
   0x00000000004d91e5 <+85>:	callq  0x4c9740 <__tsan_atomic32_load@plt>
   0x00000000004d91ea <+90>:	mov    %eax,%ebx
   0x00000000004d91ec <+92>:	nop

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
138	    uint32_t before = state_.load(std::memory_order_acquire);
   0x00000000004d91ed <+93>:	lea    -0x5c(%rbp),%rax
   0x00000000004d91f1 <+97>:	mov    %rax,%rdi
   0x00000000004d91f4 <+100>:	callq  0x4ca4c0 <__tsan_write4@plt>
   0x00000000004d91f9 <+105>:	mov    %ebx,-0x5c(%rbp)

139	
140	    assert(before == INIT || before == WAITING || before == TIMED_OUT);
   0x00000000004d91fc <+108>:	lea    -0x5c(%rbp),%rax
   0x00000000004d9200 <+112>:	mov    %rax,%rdi
   0x00000000004d9203 <+115>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d9208 <+120>:	mov    -0x5c(%rbp),%eax
   0x00000000004d920b <+123>:	test   %eax,%eax
   0x00000000004d920d <+125>:	je     0x4d9256 <folly::Baton<true, std::atomic>::post()+198>
   0x00000000004d920f <+127>:	lea    -0x5c(%rbp),%rax
   0x00000000004d9213 <+131>:	mov    %rax,%rdi
   0x00000000004d9216 <+134>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d921b <+139>:	mov    -0x5c(%rbp),%eax
   0x00000000004d921e <+142>:	cmp    $0x2,%eax
   0x00000000004d9221 <+145>:	je     0x4d9256 <folly::Baton<true, std::atomic>::post()+198>
   0x00000000004d9223 <+147>:	lea    -0x5c(%rbp),%rax
   0x00000000004d9227 <+151>:	mov    %rax,%rdi
   0x00000000004d922a <+154>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d922f <+159>:	mov    -0x5c(%rbp),%eax
   0x00000000004d9232 <+162>:	cmp    $0x4,%eax
   0x00000000004d9235 <+165>:	je     0x4d9256 <folly::Baton<true, std::atomic>::post()+198>
   0x00000000004d9237 <+167>:	lea    0x34577a(%rip),%rcx        # 0x81e9b8
   0x00000000004d923e <+174>:	mov    $0x8c,%edx
   0x00000000004d9243 <+179>:	lea    0x344dee(%rip),%rsi        # 0x81e038
   0x00000000004d924a <+186>:	lea    0x3457c7(%rip),%rdi        # 0x81ea18
   0x00000000004d9251 <+193>:	callq  0x4c9240 <__assert_fail@plt>

141	
142	    if (before == INIT &&
   0x00000000004d9256 <+198>:	lea    -0x5c(%rbp),%rax
   0x00000000004d925a <+202>:	mov    %rax,%rdi
   0x00000000004d925d <+205>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d9262 <+210>:	mov    -0x5c(%rbp),%eax
   0x00000000004d9265 <+213>:	test   %eax,%eax
   0x00000000004d9267 <+215>:	jne    0x4d92d2 <folly::Baton<true, std::atomic>::post()+322>
   0x00000000004d9269 <+217>:	mov    -0x68(%rbp),%rax
   0x00000000004d926d <+221>:	mov    %rax,-0x28(%rbp)
   0x00000000004d9271 <+225>:	movl   $0x1,-0x50(%rbp)
   0x00000000004d9278 <+232>:	movl   $0x3,-0x4c(%rbp)
   0x00000000004d927f <+239>:	movl   $0x0,-0x48(%rbp)

/usr/include/c++/9/bits/atomic_base.h:
496		memory_order __b2 = __m2 & __memory_order_mask;
   0x00000000004d9286 <+246>:	mov    -0x48(%rbp),%eax
   0x00000000004d9289 <+249>:	mov    $0xffff,%esi
   0x00000000004d928e <+254>:	mov    %eax,%edi
   0x00000000004d9290 <+256>:	callq  0x4d23a6 <std::operator&(std::memory_order, std::__memory_order_modifier)>
   0x00000000004d9295 <+261>:	mov    %eax,-0x44(%rbp)

497		memory_order __b1 = __m1 & __memory_order_mask;
   0x00000000004d9298 <+264>:	mov    -0x4c(%rbp),%eax
   0x00000000004d929b <+267>:	mov    $0xffff,%esi
   0x00000000004d92a0 <+272>:	mov    %eax,%edi
   0x00000000004d92a2 <+274>:	callq  0x4d23a6 <std::operator&(std::memory_order, std::__memory_order_modifier)>
   0x00000000004d92a7 <+279>:	mov    %eax,-0x40(%rbp)

498		__glibcxx_assert(__b2 != memory_order_release);
499		__glibcxx_assert(__b2 != memory_order_acq_rel);
500		__glibcxx_assert(__b2 <= __b1);
501	
502		return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0,
   0x00000000004d92aa <+282>:	mov    -0x48(%rbp),%edi
   0x00000000004d92ad <+285>:	mov    -0x4c(%rbp),%ecx
   0x00000000004d92b0 <+288>:	mov    -0x28(%rbp),%rax
   0x00000000004d92b4 <+292>:	mov    -0x50(%rbp),%edx
   0x00000000004d92b7 <+295>:	lea    -0x5c(%rbp),%rsi
   0x00000000004d92bb <+299>:	mov    %edi,%r8d
   0x00000000004d92be <+302>:	mov    %rax,%rdi
   0x00000000004d92c1 <+305>:	callq  0x4ca2f0 <__tsan_atomic32_compare_exchange_strong@plt>

503						   int(__m1), int(__m2));
   0x00000000004d92c6 <+310>:	nop

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
142	    if (before == INIT &&
   0x00000000004d92c7 <+311>:	test   %al,%al
   0x00000000004d92c9 <+313>:	je     0x4d92d2 <folly::Baton<true, std::atomic>::post()+322>
   0x00000000004d92cb <+315>:	mov    $0x1,%eax
   0x00000000004d92d0 <+320>:	jmp    0x4d92d7 <folly::Baton<true, std::atomic>::post()+327>
   0x00000000004d92d2 <+322>:	mov    $0x0,%eax
   0x00000000004d92d7 <+327>:	test   %al,%al
   0x00000000004d92d9 <+329>:	jne    0x4d93c6 <folly::Baton<true, std::atomic>::post()+566>

149	    }
150	
151	    assert(before == WAITING || before == TIMED_OUT);
   0x00000000004d92df <+335>:	lea    -0x5c(%rbp),%rax
   0x00000000004d92e3 <+339>:	mov    %rax,%rdi
   0x00000000004d92e6 <+342>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d92eb <+347>:	mov    -0x5c(%rbp),%eax
   0x00000000004d92ee <+350>:	cmp    $0x2,%eax
   0x00000000004d92f1 <+353>:	je     0x4d9326 <folly::Baton<true, std::atomic>::post()+406>
   0x00000000004d92f3 <+355>:	lea    -0x5c(%rbp),%rax
   0x00000000004d92f7 <+359>:	mov    %rax,%rdi
   0x00000000004d92fa <+362>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d92ff <+367>:	mov    -0x5c(%rbp),%eax
   0x00000000004d9302 <+370>:	cmp    $0x4,%eax
   0x00000000004d9305 <+373>:	je     0x4d9326 <folly::Baton<true, std::atomic>::post()+406>
   0x00000000004d9307 <+375>:	lea    0x3456aa(%rip),%rcx        # 0x81e9b8
   0x00000000004d930e <+382>:	mov    $0x97,%edx
   0x00000000004d9313 <+387>:	lea    0x344d1e(%rip),%rsi        # 0x81e038
   0x00000000004d931a <+394>:	lea    0x345737(%rip),%rdi        # 0x81ea58
   0x00000000004d9321 <+401>:	callq  0x4c9240 <__assert_fail@plt>

152	
153	    if (before == TIMED_OUT) {
   0x00000000004d9326 <+406>:	lea    -0x5c(%rbp),%rax
   0x00000000004d932a <+410>:	mov    %rax,%rdi
   0x00000000004d932d <+413>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d9332 <+418>:	mov    -0x5c(%rbp),%eax
   0x00000000004d9335 <+421>:	cmp    $0x4,%eax
   0x00000000004d9338 <+424>:	je     0x4d93c9 <folly::Baton<true, std::atomic>::post()+569>

155	    }
156	
157	    assert(before == WAITING);
   0x00000000004d933e <+430>:	lea    -0x5c(%rbp),%rax
   0x00000000004d9342 <+434>:	mov    %rax,%rdi
   0x00000000004d9345 <+437>:	callq  0x4c9760 <__tsan_read4@plt>
   0x00000000004d934a <+442>:	mov    -0x5c(%rbp),%eax
   0x00000000004d934d <+445>:	cmp    $0x2,%eax
   0x00000000004d9350 <+448>:	je     0x4d9371 <folly::Baton<true, std::atomic>::post()+481>
   0x00000000004d9352 <+450>:	lea    0x34565f(%rip),%rcx        # 0x81e9b8
   0x00000000004d9359 <+457>:	mov    $0x9d,%edx
   0x00000000004d935e <+462>:	lea    0x344cd3(%rip),%rsi        # 0x81e038
   0x00000000004d9365 <+469>:	lea    0x345715(%rip),%rdi        # 0x81ea81
   0x00000000004d936c <+476>:	callq  0x4c9240 <__assert_fail@plt>

158	    state_.store(LATE_DELIVERY, std::memory_order_release);
   0x00000000004d9371 <+481>:	mov    -0x68(%rbp),%rax
   0x00000000004d9375 <+485>:	mov    %rax,-0x20(%rbp)
   0x00000000004d9379 <+489>:	movl   $0x3,-0x3c(%rbp)
   0x00000000004d9380 <+496>:	movl   $0x3,-0x38(%rbp)

/usr/include/c++/9/bits/atomic_base.h:
392		memory_order __b = __m & __memory_order_mask;
   0x00000000004d9387 <+503>:	mov    -0x38(%rbp),%eax
   0x00000000004d938a <+506>:	mov    $0xffff,%esi
   0x00000000004d938f <+511>:	mov    %eax,%edi
   0x00000000004d9391 <+513>:	callq  0x4d23a6 <std::operator&(std::memory_order, std::__memory_order_modifier)>
   0x00000000004d9396 <+518>:	mov    %eax,-0x34(%rbp)

393		__glibcxx_assert(__b != memory_order_acquire);
394		__glibcxx_assert(__b != memory_order_acq_rel);
395		__glibcxx_assert(__b != memory_order_consume);
396	
397		__atomic_store_n(&_M_i, __i, int(__m));
   0x00000000004d9399 <+521>:	mov    -0x38(%rbp),%edx
   0x00000000004d939c <+524>:	mov    -0x20(%rbp),%rax
   0x00000000004d93a0 <+528>:	mov    -0x3c(%rbp),%ecx
   0x00000000004d93a3 <+531>:	mov    %ecx,%esi
   0x00000000004d93a5 <+533>:	mov    %rax,%rdi
   0x00000000004d93a8 <+536>:	callq  0x4c8f30 <__tsan_atomic32_store@plt>

398	      }
   0x00000000004d93ad <+541>:	nop

/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/synchronization/Baton.h:
159	    detail::futexWake(&state_, 1);
   0x00000000004d93ae <+542>:	mov    -0x68(%rbp),%rax
   0x00000000004d93b2 <+546>:	mov    $0xffffffff,%edx
   0x00000000004d93b7 <+551>:	mov    $0x1,%esi
   0x00000000004d93bc <+556>:	mov    %rax,%rdi
   0x00000000004d93bf <+559>:	callq  0x4dc49c <folly::detail::futexWake<std::atomic<unsigned int> >(std::atomic<unsigned int> const*, int, unsigned int)>
   0x00000000004d93c4 <+564>:	jmp    0x4d93ca <folly::Baton<true, std::atomic>::post()+570>

148	      return;
   0x00000000004d93c6 <+566>:	nop
   0x00000000004d93c7 <+567>:	jmp    0x4d93ca <folly::Baton<true, std::atomic>::post()+570>

154	      return;
   0x00000000004d93c9 <+569>:	nop
   0x00000000004d93ca <+570>:	callq  0x4c9d50 <__tsan_func_exit@plt>

160	  }
   0x00000000004d93cf <+575>:	mov    -0x18(%rbp),%rax
   0x00000000004d93d3 <+579>:	xor    %fs:0x28,%rax
   0x00000000004d93dc <+588>:	je     0x4d93e3 <folly::Baton<true, std::atomic>::post()+595>
   0x00000000004d93de <+590>:	callq  0x4c95a0 <__stack_chk_fail@plt>
   0x00000000004d93e3 <+595>:	add    $0x68,%rsp
   0x00000000004d93e7 <+599>:	pop    %rbx
   0x00000000004d93e8 <+600>:	pop    %rbp
   0x00000000004d93e9 <+601>:	retq     
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment