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

Fix typo (templetized => templatized) in Frozen.h #2

Closed
wants to merge 1 commit into from

Conversation

ajtulloch
Copy link
Contributor

- http://en.wiktionary.org/wiki/templatize
- "templatized C++" has ~300,000 Google results, "templetized C++" has O(1,500) results.
@lbrandy
Copy link

lbrandy commented Feb 20, 2014

ubn

@aatallah
Copy link

+1 on UBN

@djwatson
Copy link

merged

@djwatson djwatson closed this Feb 21, 2014
@ajtulloch ajtulloch deleted the patch-1 branch February 22, 2014 06:07
pavlo-fb pushed a commit that referenced this pull request Nov 8, 2014
Summary:
So I think here is the problem:
- Request #1 fires, SASL times out, we fall back the channel to insecure mode and send a request.
- The request comes back, we detach the event base from the channel and put it in the idle pool.
- At this point the SASL thread could still be chugging along trying to talk to the KDC, etc.
- Request #2 fires, takes the channel off the idle pool, attaches another evb to it. This request is now in flight
- The SASL threads finally completes, and since we now have a valid evb on the channel it fires a saslSendServer (which schedules another timeout on the channel)
- Response #2 comes back, we try to detach from the channel but can't since there is a request in progress and a timeout set.

Test Plan: unit tests

Reviewed By: mshneer@fb.com

Subscribers: alandau, bmatheny, mshneer, wstefancik

FB internal diff: D1635252
viswanathgs pushed a commit that referenced this pull request Jan 14, 2015
Summary:
* thrift/lib/cpp/test/TAsyncSSLSocketTest.cpp:
(SSLParseClientHelloOnePacket): Declare the local int array,
"fds" to be of length 2, (not 1) as required by "getfds".
SSLParseClientHelloTwoPackets): Likewise.
(SSLParseClientHelloMultiplePackets): Likewise.

Here is the ASAN report:

==23074== ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff5b5ad5e4 at pc 0x40c7ec bp 0x7fff5b5ad3a0 sp 0x7fff5b5ad398
READ of size 4 at 0x7fff5b5ad5e4 thread T0
#0 0x40c7eb in getfds(int*) /tmp/thrift/lib/cpp/test/TAsyncSSLSocketTest.h:656
#1 0x41a57f in TAsyncSSLSocketTest_SSLParseClientHelloOnePacket_Test::TestBody() /tmp/thrift/lib/cpp/test/TAsyncSSLSocketTest.cpp:723
#2 0x563ff8 in HandleSehExceptionsInMethodIfSupported<testing::Test, void> /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/src/gtest.cc:2078
#3 0x558a24 in testing::Test::Run() /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/src/gtest.cc:2151
#4 0x558b04 in testing::TestInfo::Run() /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/src/gtest.cc:2326
#5 0x558c6e in testing::TestCase::Run() /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/src/gtest.cc:2444
#6 0x55d41c in testing::internal::UnitTestImpl::RunAllTests() /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/src/gtest.cc:4315
#7 0x55d6ff in testing::internal::UnitTestImpl::RunAllTests() /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/src/gtest.cc:4232
#8 0x542961 in RUN_ALL_TESTS /home/engshare/third-party2/gtest/1.7.0/src/gtest-1.7.0/include/gtest/gtest.h:2288
#3 0x7ffda054eefe in __libc_start_main ??:?
#10 0x40bdd8 in _start /home/engshare/third-party2/glibc/2.17/src/glibc-2.17/sysdeps/x86_64/start.S:123
Address 0x7fff5b5ad5e4 is located at offset 164 in frame <TestBody> of T0's stack:
This frame has 9 object(s):
[32, 33) 'majorVersion'
[96, 97) 'minorVersion'
[160, 164) 'fds'

Interestingly, this began showing up in my nightly test results
only around Dec 29th or so, even though the blamed diff is from months ago.

Test Plan:
Run these commands and confirm there are no more ASAN aborts:
fbconfig --sanitize=address thrift/lib/cpp/test:TAsyncSSLSocketTest
fbmake runtests

Reviewed By: pgriess@fb.com, sugak@fb.com

Subscribers: net-systems@, alandau, bmatheny, mshneer, sugak

FB internal diff: D1778820

Tasks: 2392412

Signature: t1:1778820:1421114269:aa0f1d9470fd19eed7c3101dc38a28dc360051ad
ghost pushed a commit that referenced this pull request Feb 6, 2016
…er-free in a test

Summary:
Building/testing with gcc-4.9+ASAN would fail with this SIOF error:

  =================================================================
  ==2063684==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x000000eb4440 at pc 0x4e965e bp 0x7ffeb572d3f0 sp 0x7ffeb572d3e8
  READ of size 4 at 0x000000eb4440 thread T0
      #0 0x4e965d in apache::thrift::BaseThriftServer::BaseThriftServer() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x4e965d)
      #1 0x4daaf7 in apache::thrift::ThriftServer::ThriftServer(std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > const&, bool) thrift/lib/cpp2/server/ThriftServer.cpp:94
      #2 0x4daa29 in apache::thrift::ThriftServer::ThriftServer() thrift/lib/cpp2/server/ThriftServer.cpp:88
      #3 0x44f587 in void __gnu_cxx::new_allocator<apache::thrift::ThriftServer>::construct<apache::thrift::ThriftServer>(apache::thrift::ThriftServer*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44f587)
      #4 0x44efd9 in std::enable_if<std::allocator_traits<std::allocator<apache::thrift::ThriftServer> >::__construct_helper<apache::thrift::ThriftServer>::type::value, void>::type std::allocator_traits<std::allocator<apache::thrift::ThriftServer> >::_S_construct<apache::thrift::ThriftServer>(std::allocator<apache::thrift::ThriftServer>&, apache::thrift::ThriftServer*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44efd9)
      #5 0x44eb23 in decltype (_S_construct({parm#1}, {parm#2})) std::allocator_traits<std::allocator<apache::thrift::ThriftServer> >::construct<apache::thrift::ThriftServer>(std::allocator<apache::thrift::ThriftServer>&, apache::thrift::ThriftServer*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44eb23)
      #6 0x44e5ac in std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<apache::thrift::ThriftServer>) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44e5ac)
      #7 0x44dd7e in void __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2> >::construct<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>, std::allocator<apache::thrift::ThriftServer> const>(std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>*, std::allocator<apache::thrift::ThriftServer> const&&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44dd7e)
      #8 0x44d4ee in std::enable_if<std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2> > >::__construct_helper<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>, std::allocator<apache::thrift::ThriftServer> const>::type::value, void>::type std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2> > >::_S_construct<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>, std::allocator<apache::thrift::ThriftServer> const>(std::allocator<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2> >&, std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>*, std::allocator<apache::thrift::ThriftServer> const&&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44d4ee)
      #9 0x44c10e in decltype (_S_construct({parm#1}, {parm#2}, (forward<std::allocator<apache::thrift::ThriftServer> const>)({parm#3}))) std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2> > >::construct<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>, std::allocator<apache::thrift::ThriftServer> const>(std::allocator<std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2> >&, std::_Sp_counted_ptr_inplace<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>, (__gnu_cxx::_Lock_policy)2>*, std::allocator<apache::thrift::ThriftServer> const&&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44c10e)
      #10 0x44abb7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>>(std::_Sp_make_shared_tag, apache::thrift::ThriftServer*, std::allocator<apache::thrift::ThriftServer> const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44abb7)
      #11 0x448143 in std::__shared_ptr<apache::thrift::ThriftServer, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<apache::thrift::ThriftServer>>(std::_Sp_make_shared_tag, std::allocator<apache::thrift::ThriftServer> const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x448143)
      #12 0x44496d in std::shared_ptr<apache::thrift::ThriftServer>::shared_ptr<std::allocator<apache::thrift::ThriftServer>>(std::_Sp_make_shared_tag, std::allocator<apache::thrift::ThriftServer> const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x44496d)
      #13 0x43f179 in std::shared_ptr<apache::thrift::ThriftServer> std::allocate_shared<apache::thrift::ThriftServer, std::allocator<apache::thrift::ThriftServer>>(std::allocator<apache::thrift::ThriftServer> const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x43f179)
      #14 0x437d94 in std::shared_ptr<apache::thrift::ThriftServer> std::make_shared<apache::thrift::ThriftServer>() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x437d94)
      #15 0x43158b in apache::thrift::TestThriftServerFactory<StreamingServiceInterface>::create() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/lib/cpp2/test/StreamingTest+0x43158b)
      #16 0x41e676 in __static_initialization_and_destruction_0 thrift/lib/cpp2/test/StreamingTest.cpp:57
      #17 0x41e946 in _GLOBAL__sub_I_factory thrift/lib/cpp2/test/StreamingTest.cpp:219
      #18 0xa63eee in __libc_csu_init /home/engshare/third-party2/glibc/2.20/src/glibc-2.20/csu/elf-init.c:88
      #19 0x7fd9cc787084 in __libc_start_main (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libc.so.6+0x20084)
      #0 0x414ba5 in _start /home/engshare/third-party2/glibc/2.20/src/glibc-2.20/csu/../sysdeps/x86_64/start.S:122

The fix is to make "sst" a meyers singleton. This is only a test, and it now works, so not worth seeing if we might actually need folly::Singleton.
There was also a heap use after free:

  [==========] Running 1 test from 1 test case.
  [----------] Global test environment set-up.
  [----------] 1 test from FetcherHandlerTest
  [ RUN      ] FetcherHandlerTest.example_pass
  =================================================================
  ==2542675==ERROR: AddressSanitizer: heap-use-after-free on address 0x61100003be00 at pc 0x51a786 bp 0x7fe84e344a60 sp 0x7fe84e344a58
  READ of size 4 at 0x61100003be00 thread T5
      #0 0x51a785 in folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::Try(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/futures/Try-inl.h:26
      #1 0x518eac in void folly::Optional<folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::construct<folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/Optional.h:266
      #2 0x517b49 in folly::Optional<folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::Optional(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/Optional.h:128
      #3 0x515297 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::Core(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/futures/detail/Core.h:88
      #4 0x5143e0 in folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > folly::makeFuture<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/futures/Future-inl.h:543
      #5 0x50954d in folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::ensure<apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}>(apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4})::{lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)#1}::operator()(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x50954d)
      #6 0x50a8d5 in std::enable_if<folly::detail::callableResult<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&>::ReturnsFuture::value, folly::detail::callableResult<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&>::Return>::type folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::thenImplementation<folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::ensure<apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}>(apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4})::{lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)#1}, folly::detail::callableResult<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&>, true, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >(apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}, {lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)#1}::argResult<true, apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >)::{lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >)#1}::operator()(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x50a8d5)
      #7 0x50ecad in operator() folly/futures/detail/Core.h:137
      #8 0x50dd99 in _M_invoke third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2069
      #9 0x51909e in std::function<void (folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)>::operator()(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) const third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2439
      #10 0x5172c2 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::doCallback() folly/futures/detail/Core.h:355
      #11 0x51503b in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#2}::operator()() const (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51503b)
      #12 0x5175c3 in bool folly::detail::FSM<folly::detail::State>::updateState<folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#1}, folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#2}>(folly::detail::State, folly::detail::State, folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#1} const&, folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#2} const&) folly/futures/detail/FSM.h:100
      #13 0x5150b8 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback() folly/futures/detail/Core.h:309
      #14 0x5141d4 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::setResult(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/futures/detail/Core.h:204
      #15 0x513c2a in folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::setTry(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) folly/futures/Promise-inl.h:117
      #16 0x5128d4 in void folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::setValue<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >(std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >&&) folly/futures/Promise-inl.h:126
      #17 0x508a26 in apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda(std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >)#1}::operator()(std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >) const (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x508a26)
      #18 0x5097d5 in _M_invoke third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2039
      #19 0x51fb74 in std::function<void (std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > const&)>::operator()(std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > const&) const third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2439
      #20 0x51f1a3 in apache::thrift::tutorial::fetcher::HttpFetcher::readEOF() thrift/tutorial/cpp/async/fetcher/HttpFetcher.cpp:88
      #21 0x83c394 in folly::AsyncSocket::handleRead() folly/io/async/AsyncSocket.cpp:1405
      #22 0x83a742 in folly::AsyncSocket::ioReady(unsigned short) folly/io/async/AsyncSocket.cpp:1245
      #23 0x8448f7 in folly::AsyncSocket::IoHandler::handlerReady(unsigned short) folly/io/async/AsyncSocket.h:634
      #24 0x860b30 in folly::EventHandler::libeventCallback(int, short, void*) folly/io/async/EventHandler.cpp:160
      #25 0xa51889 in event_process_active /home/engshare/third-party2/libevent/1.4.14b_hphp/src/libevent-1.4.14b-stable/event.c:390
      #26 0xa51a8f in event_base_loop /home/engshare/third-party2/libevent/1.4.14b_hphp/src/libevent-1.4.14b-stable/event.c:532
      #27 0x84c201 in folly::EventBase::loopBody(int) folly/io/async/EventBase.cpp:335
      #28 0x84bcc6 in folly::EventBase::loop() folly/io/async/EventBase.cpp:287
      #29 0x84d3d2 in folly::EventBase::loopForever() folly/io/async/EventBase.cpp:435
      #30 0x67e771 in wangle::IOThreadPoolExecutor::threadRun(std::shared_ptr<wangle::ThreadPoolExecutor::Thread>) wangle/concurrent/IOThreadPoolExecutor.cpp:149
      #31 0x693623 in void std::_Mem_fn<void (wangle::ThreadPoolExecutor::*)(std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)>::operator()<std::shared_ptr<wangle::ThreadPoolExecutor::Thread>&, void>(wangle::ThreadPoolExecutor*, std::shared_ptr<wangle::ThreadPoolExecutor::Thread>&) const (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x693623)
      #32 0x691902 in void std::_Bind<std::_Mem_fn<void (wangle::ThreadPoolExecutor::*)(std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)> (wangle::ThreadPoolExecutor*, std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:1264
      #33 0x68e593 in void std::_Bind<std::_Mem_fn<void (wangle::ThreadPoolExecutor::*)(std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)> (wangle::ThreadPoolExecutor*, std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)>::operator()<, void>() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x68e593)
      #34 0x68b733 in std::_Function_handler<void (), std::_Bind<std::_Mem_fn<void (wangle::ThreadPoolExecutor::*)(std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)> (wangle::ThreadPoolExecutor*, std::shared_ptr<wangle::ThreadPoolExecutor::Thread>)> >::_M_invoke(std::_Any_data const&) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2039
      #35 0x43827b in std::function<void ()>::operator()() const third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2439
      #36 0x4b5eb7 in void std::_Bind_simple<std::function<void ()> ()>::_M_invoke<>(std::_Index_tuple<>) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:1700
      #37 0x4b4dae in std::_Bind_simple<std::function<void ()> ()>::operator()() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:1688
      #38 0x4b2f17 in std::thread::_Impl<std::_Bind_simple<std::function<void ()> ()> >::_M_run() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/thread:115
      #39 0x7fe853c6c360 in execute_native_thread_routine (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libstdc++.so.6+0xe5360)
      #40 0x7fe8543067f0 in start_thread (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libpthread.so.0+0x77f0)
      #41 0x7fe854d5046c in __clone (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libc.so.6+0x10d46c)

  0x61100003be00 is located 64 bytes inside of 208-byte region [0x61100003bdc0,0x61100003be90)
  freed by thread T5 here:
      #0 0x7fe855b89937 in operator delete(void*) (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libasan.so.1+0x59937)
      #1 0x518f5d in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::detachOne() folly/futures/detail/Core.h:364
      #2 0x51b424 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::detachPromise() folly/futures/detail/Core.h:221
      #3 0x519e6e in folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::detach() folly/futures/Promise-inl.h:72
      #4 0x517c5d in folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::~Promise() folly/futures/Promise-inl.h:64
      #5 0x51e799 in void __gnu_cxx::new_allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::destroy<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >(folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51e799)
      #6 0x51e64d in std::enable_if<std::allocator_traits<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >::__destroy_helper<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::type::value, void>::type std::allocator_traits<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >::_S_destroy<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >(std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >&, folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51e64d)
      #7 0x51e545 in void std::allocator_traits<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >::destroy<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >(std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >&, folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/bits/alloc_traits.h:398
      #8 0x51e2c8 in std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>::_M_dispose() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/bits/shared_ptr_base.h:524
      #9 0x422436 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/bits/shared_ptr_base.h:149
      #10 0x41f177 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/bits/shared_ptr_base.h:666
      #11 0x511ad7 in std::__shared_ptr<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x511ad7)
      #12 0x511af1 in std::shared_ptr<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::~shared_ptr() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x511af1)
      #13 0x508a45 in apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda(std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >)#1}::~basic_fbstring() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x508a45)
      #14 0x509fdd in _M_destroy third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:1894
      #15 0x509947 in _M_manager third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:1918
      #16 0x418581 in std::_Function_base::~_Function_base() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:1998
      #17 0x511831 in std::function<void (std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > const&)>::~function() third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2142
      #18 0x51fdd2 in apache::thrift::tutorial::fetcher::HttpFetcher::~HttpFetcher() thrift/tutorial/cpp/async/fetcher/HttpFetcher.h:33
      #19 0x51fe37 in apache::thrift::tutorial::fetcher::HttpFetcher::~HttpFetcher() thrift/tutorial/cpp/async/fetcher/HttpFetcher.h:33
      #20 0x508d4b in apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}::operator()() const (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x508d4b)
      #21 0x50952f in folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::ensure<apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}>(apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4})::{lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)#1}::operator()(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x50952f)
      #22 0x50a8d5 in std::enable_if<folly::detail::callableResult<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&>::ReturnsFuture::value, folly::detail::callableResult<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&>::Return>::type folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::thenImplementation<folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > folly::Future<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::ensure<apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}>(apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4})::{lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)#1}, folly::detail::callableResult<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> >, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&>, true, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >(apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}, {lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)#1}::argResult<true, apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#4}, folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >)::{lambda(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >)#1}::operator()(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x50a8d5)
      #23 0x50ecad in operator() folly/futures/detail/Core.h:137
      #24 0x50dd99 in _M_invoke third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2069
      #25 0x51909e in std::function<void (folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&)>::operator()(folly::Try<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >&&) const third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2439
      #26 0x5172c2 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::doCallback() folly/futures/detail/Core.h:355
      #27 0x51503b in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#2}::operator()() const (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51503b)
      #28 0x5175c3 in bool folly::detail::FSM<folly::detail::State>::updateState<folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#1}, folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#2}>(folly::detail::State, folly::detail::State, folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#1} const&, folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback()::{lambda()#2} const&) folly/futures/detail/FSM.h:100
      #29 0x5150b8 in folly::detail::Core<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::maybeCallback() folly/futures/detail/Core.h:309

  previously allocated by thread T2 here:
      #0 0x7fe855b894bf in operator new(unsigned long) (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libasan.so.1+0x594bf)
      #1 0x517c05 in folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >::Promise() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x517c05)
      #2 0x51d6e3 in void __gnu_cxx::new_allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::construct<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >>(folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51d6e3)
      #3 0x51d501 in std::enable_if<std::allocator_traits<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >::__construct_helper<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >>::type::value, void>::type std::allocator_traits<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >::_S_construct<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >>(std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >&, folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51d501)
      #4 0x51d2eb in decltype (_S_construct({parm#1}, {parm#2})) std::allocator_traits<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >::construct<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >>(std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >&, folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51d2eb)
      #5 0x51d07e in std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51d07e)
      #6 0x51c6e6 in void __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2> >::construct<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const>(std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>*, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51c6e6)
      #7 0x51bbed in std::enable_if<std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2> > >::__construct_helper<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const>::type::value, void>::type std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2> > >::_S_construct<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const>(std::allocator<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2> >&, std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>*, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&&) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/bits/alloc_traits.h:247
      #8 0x51a70e in decltype (_S_construct({parm#1}, {parm#2}, (forward<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const>)({parm#3}))) std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2> > >::construct<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const>(std::allocator<std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2> >&, std::_Sp_counted_ptr_inplace<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >, (__gnu_cxx::_Lock_policy)2>*, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51a70e)
      #9 0x518b99 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >>(std::_Sp_make_shared_tag, folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >*, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x518b99)
      #10 0x51676b in std::__shared_ptr<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >>(std::_Sp_make_shared_tag, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x51676b)
      #11 0x514edf in std::shared_ptr<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >::shared_ptr<std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >>(std::_Sp_make_shared_tag, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x514edf)
      #12 0x513b01 in std::shared_ptr<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > std::allocate_shared<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > >>(std::allocator<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > const&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x513b01)
      #13 0x512762 in std::shared_ptr<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > std::make_shared<folly::Promise<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >>() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x512762)
      #14 0x508e59 in apache::thrift::tutorial::fetcher::FetcherHandler::future_fetchHttp(apache::thrift::tutorial::fetcher::FetchHttpRequest const&) thrift/tutorial/cpp/async/fetcher/FetcherHandler.cpp:35
      #15 0x520405 in apache::thrift::tutorial::fetcher::FetcherSvIf::async_tm_fetchHttp(std::unique_ptr<apache::thrift::HandlerCallback<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::default_delete<apache::thrift::HandlerCallback<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >, apache::thrift::tutorial::fetcher::FetchHttpRequest const&)::{lambda()#1}::operator()() const (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x520405)
      #16 0x520ae2 in future_catching<apache::thrift::tutorial::fetcher::FetcherSvIf::async_tm_fetchHttp(std::unique_ptr<apache::thrift::HandlerCallback<std::basic_fbstring<char> > >, const apache::thrift::tutorial::fetcher::FetchHttpRequest&)::<lambda()> > thrift/lib/cpp2/GeneratedCodeHelper.h:1090
      #17 0x520966 in async_tm<apache::thrift::tutorial::fetcher::FetcherSvIf::async_tm_fetchHttp(std::unique_ptr<apache::thrift::HandlerCallback<std::basic_fbstring<char> > >, const apache::thrift::tutorial::fetcher::FetchHttpRequest&)::<lambda()> > thrift/lib/cpp2/GeneratedCodeHelper.h:1127
      #18 0x52046b in apache::thrift::tutorial::fetcher::FetcherSvIf::async_tm_fetchHttp(std::unique_ptr<apache::thrift::HandlerCallback<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > >, std::default_delete<apache::thrift::HandlerCallback<std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > > > >, apache::thrift::tutorial::fetcher::FetchHttpRequest const&) _build/dbg/thrift/tutorial/cpp/async/fetcher/if-cpp2.thrift-gen/fetcher/gen-cpp2/Fetcher.cpp:29
      #19 0x53ba31 in void apache::thrift::tutorial::fetcher::FetcherAsyncProcessor::process_fetchHttp<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter>(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x53ba31)
      #20 0x53ca85 in void apache::thrift::GeneratedAsyncProcessor::processInThread<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter, void (apache::thrift::tutorial::fetcher::FetcherAsyncProcessor::*)(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*), apache::thrift::tutorial::fetcher::FetcherAsyncProcessor>(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*, apache::thrift::concurrency::PRIORITY, bool, void (apache::thrift::tutorial::fetcher::FetcherAsyncProcessor::*)(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*), apache::thrift::tutorial::fetcher::FetcherAsyncProcessor*)::{lambda()#1}::operator()() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x53ca85)
      #21 0x55b10a in std::_Function_handler<void (), void apache::thrift::GeneratedAsyncProcessor::processInThread<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter, void (apache::thrift::tutorial::fetcher::FetcherAsyncProcessor::*)(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*), apache::thrift::tutorial::fetcher::FetcherAsyncProcessor>(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*, apache::thrift::concurrency::PRIORITY, bool, void (apache::thrift::tutorial::fetcher::FetcherAsyncProcessor::*)(std::unique_ptr<apache::thrift::ResponseChannel::Request, std::default_delete<apache::thrift::ResponseChannel::Request> >, std::unique_ptr<folly::IOBuf, std::default_delete<folly::IOBuf> >, std::unique_ptr<apache::thrift::CompactProtocolReader, std::default_delete<apache::thrift::CompactProtocolReader> >, apache::thrift::Cpp2RequestContext*, folly::EventBase*, apache::thrift::concurrency::ThreadManager*), apache::thrift::tutorial::fetcher::FetcherAsyncProcessor*)::{lambda()#1}>::_M_invoke(std::_Any_data const&) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2039
      #22 0x43827b in std::function<void ()>::operator()() const third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/functional:2439
      #23 0x526dc0 in apache::thrift::EventTask::run() thrift/lib/cpp2/async/AsyncProcessor.h:61
      #24 0x43594a in apache::thrift::concurrency::ThreadManager::Task::run() thrift/lib/cpp/concurrency/ThreadManager-impl.h:59
      #25 0x455b8f in apache::thrift::concurrency::ThreadManager::ImplT<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic> > >::Worker<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic> > >::run() thrift/lib/cpp/concurrency/ThreadManager.tcc:122
      #26 0x79d9e5 in apache::thrift::concurrency::PthreadThread::threadMain(void*) thrift/lib/cpp/concurrency/PosixThreadFactory.cpp:194
      #27 0x7fe8543067f0 in start_thread (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libpthread.so.0+0x77f0)

  Thread T5 created by T3 here:
      #0 0x7fe855b5753a in pthread_create (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libasan.so.1+0x2753a)
      #1 0x7fe853c6daff in std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>) (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libstdc++.so.6+0xe6aff)
      #2 0x472a4e in std::thread::thread<std::function<void ()>>(std::function<void ()>&&) third-party2/libgcc/4.9.x/gcc-4.9-glibc-2.20-fb/024dbc3/include/c++/4.9.x/thread:135
      #3 0x469114 in wangle::NamedThreadFactory::newThread(std::function<void ()>&&) (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x469114)
      #4 0x684ed7 in wangle::ThreadPoolExecutor::addThreads(unsigned long) wangle/concurrent/ThreadPoolExecutor.cpp:92
      #5 0x684b1b in wangle::ThreadPoolExecutor::setNumThreads(unsigned long) wangle/concurrent/ThreadPoolExecutor.cpp:76
      #6 0x45febf in apache::thrift::ThriftServer::setup() thrift/lib/cpp2/server/ThriftServer.cpp:290
      #7 0x460b19 in apache::thrift::ThriftServer::serve() thrift/lib/cpp2/server/ThriftServer.cpp:351
      #8 0x61ddaa in apache::thrift::util::ScopedServerThread::Helper::run() thrift/lib/cpp/util/ScopedServerThread.cpp:173
      #9 0x79d9e5 in apache::thrift::concurrency::PthreadThread::threadMain(void*) thrift/lib/cpp/concurrency/PosixThreadFactory.cpp:194
      #10 0x7fe8543067f0 in start_thread (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libpthread.so.0+0x77f0)

  Thread T3 created by T0 here:
      #0 0x7fe855b5753a in pthread_create (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libasan.so.1+0x2753a)
      #1 0x79c951 in apache::thrift::concurrency::PthreadThread::start() thrift/lib/cpp/concurrency/PosixThreadFactory.cpp:108
      #2 0x61e9a0 in apache::thrift::util::ScopedServerThread::start(std::shared_ptr<apache::thrift::server::TServer> const&) thrift/lib/cpp/util/ScopedServerThread.cpp:259
      #3 0x430dd8 in apache::thrift::ScopedServerInterfaceThread::ScopedServerInterfaceThread(std::shared_ptr<apache::thrift::AsyncProcessorFactory>, std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > const&, unsigned short) thrift/lib/cpp2/util/ScopedServerInterfaceThread.cpp:41
      #4 0x415c3b in FetcherHandlerTest_example_pass_Test::TestBody() thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest.cpp:94
      #5 0x99e3b7 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) src/gtest.cc:2364
      #6 0x99e3b7 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) src/gtest.cc:2400
      #7 0x9902e4 in testing::Test::Run() src/gtest.cc:2437
      #8 0x9904b7 in testing::TestInfo::Run() src/gtest.cc:2612
      #9 0x9906d4 in testing::TestInfo::Run() src/gtest.cc:2587
      #10 0x9906d4 in testing::TestCase::Run() src/gtest.cc:2730
      #11 0x991bce in testing::TestCase::Run() src/gtest.cc:4571
      #12 0x991bce in testing::internal::UnitTestImpl::RunAllTests() src/gtest.cc:4602
      #13 0x991e39 in testing::internal::UnitTestImpl::RunAllTests() src/gtest.cc:4519
      #14 0x991e39 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) src/gtest.cc:2364
      #15 0x991e39 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) src/gtest.cc:2400
      #16 0x991e39 in testing::UnitTest::Run() src/gtest.cc:4223
      #17 0x6734e1 in RUN_ALL_TESTS() third-party2/gtest/1.7.0/gcc-4.9-glibc-2.20-fb/e9936bf/include/gtest/gtest.h:2326
      #18 0x67343d in main common/gtest/LightMain.cpp:9
      #19 0x7fe854c630f5 in __libc_start_main (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libc.so.6+0x200f5)
      #20 0x414be5 (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x414be5)

  Thread T2 created by T0 here:
      #0 0x7fe855b5753a in pthread_create (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libasan.so.1+0x2753a)
      #1 0x79c951 in apache::thrift::concurrency::PthreadThread::start() thrift/lib/cpp/concurrency/PosixThreadFactory.cpp:108
      #2 0x4501c7 in apache::thrift::concurrency::ThreadManager::ImplT<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic> > >::addWorker(unsigned long) thrift/lib/cpp/concurrency/ThreadManager.tcc:161
      #3 0x44f868 in apache::thrift::concurrency::SimpleThreadManager<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic> > >::start() (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x44f868)
      #4 0x430c96 in apache::thrift::ScopedServerInterfaceThread::ScopedServerInterfaceThread(std::shared_ptr<apache::thrift::AsyncProcessorFactory>, std::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, std::fbstring_core<char> > const&, unsigned short) thrift/lib/cpp2/util/ScopedServerInterfaceThread.cpp:34
      #5 0x415c3b in FetcherHandlerTest_example_pass_Test::TestBody() thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest.cpp:94
      #6 0x99e3b7 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) src/gtest.cc:2364
      #7 0x99e3b7 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) src/gtest.cc:2400
      #8 0x9902e4 in testing::Test::Run() src/gtest.cc:2437
      #9 0x9904b7 in testing::TestInfo::Run() src/gtest.cc:2612
      #10 0x9906d4 in testing::TestInfo::Run() src/gtest.cc:2587
      #11 0x9906d4 in testing::TestCase::Run() src/gtest.cc:2730
      #12 0x991bce in testing::TestCase::Run() src/gtest.cc:4571
      #13 0x991bce in testing::internal::UnitTestImpl::RunAllTests() src/gtest.cc:4602
      #14 0x991e39 in testing::internal::UnitTestImpl::RunAllTests() src/gtest.cc:4519
      #15 0x991e39 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) src/gtest.cc:2364
      #16 0x991e39 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) src/gtest.cc:2400
      #17 0x991e39 in testing::UnitTest::Run() src/gtest.cc:4223
      #18 0x6734e1 in RUN_ALL_TESTS() third-party2/gtest/1.7.0/gcc-4.9-glibc-2.20-fb/e9936bf/include/gtest/gtest.h:2326
      #19 0x67343d in main common/gtest/LightMain.cpp:9
      #20 0x7fe854c630f5 in __libc_start_main (/usr/local/fbcode/gcc-4.9-glibc-2.20-fb/lib/libc.so.6+0x200f5)
      #21 0x414be5 (/data/users/meyering/fbsource/fbcode/_build/dbg/thrift/tutorial/cpp/async/fetcher/FetcherHandlerTest+0x414be5)

I'll leave that for a separate diff by someone else.

Reviewed By: alandau

Differential Revision: D2907366

fb-gh-sync-id: 3ba28c9f8361fabdff38faeb923997fd9f41da15
@yuzzjj yuzzjj mentioned this pull request May 6, 2016
facebook-github-bot pushed a commit that referenced this pull request Dec 26, 2016
Summary:
This adds a top level CMakeLists.txt file allowing to build from the top level directory using Cmake. I didn't change the top level Readme file yet as this only builds the compiler for now. I will slowly start adding CMakeLists.txt files on every required folder to build everything from the top level directory; or, build components of it(i.e. `cmake build_compiler ..`) from the top level directory as well.

Note: I had to change the executable name to `thriftcomp` as cmake makes a build tree inside build with the directories that have a `CMakeLists.txt` file. Having the binary named the same as de directory in the build tree would cause cmake to not create the binary.

There's 3 solutions for this naming problem:
1) Create the binary inside a `bin` directory in build `fbthrift/build/bin/trift`.
2) Keep the new name `thriftcomp` to have `fbthrift/build/thriftcomp`
3) Rename the directory to `fbthrift`. From `fbthrift/thrift` -> `fbthrift/fbthrift`.

I went for solution #2 but it's simple enough to move it to the other two.

Reviewed By: yfeldblum

Differential Revision: D4365856

fbshipit-source-id: 70481f0839ab28ed47fb0f9a28de119c54859038
facebook-github-bot pushed a commit that referenced this pull request Feb 18, 2017
Summary:
[Thrift] Regression unit-test for recent crash in `THttpParser`.

Filtered crash report, as reproduced by this unit-test, from reverting {D4567032} (9076ff6):

    Note: Google Test filter = THttpClientParserTest.read_encapsulated_status_line
    [==========] Running 1 test from 1 test case.
    [----------] Global test environment set-up.
    [----------] 1 test from THttpClientParserTest
    [ RUN      ] THttpClientParserTest.read_encapsulated_status_line
    ASAN:DEADLYSIGNAL
    =================================================================
    ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
    The signal is caused by a READ memory access.
    Hint: address points to the zero page.
         #1 <binary>                                        strlen
         #2 folly/portability/Constexpr.h:102               unsigned long folly::constexpr_strlen<...>(char const*)
         #3 folly/Range.h:212                               folly::Range<...>::Range<...>(char const*)
         #4 thrift/lib/cpp/util/THttpParser.cpp:208         apache::thrift::util::THttpParser::parseHeader()
         #5 thrift/lib/cpp/util/THttpParser.cpp:87          apache::thrift::util::THttpParser::readDataAvailable(unsigned long)
         #6 thrift/lib/cpp/util/test/THttpParserTest.cpp:20 (anonymous namespace)::write(apache::thrift::util::THttpParser&, folly::Range<...>)
         #7 thrift/lib/cpp/util/test/THttpParserTest.cpp:28 THttpClientParserTest_read_encapsulated_status_line_Test::TestBody()

    AddressSanitizer can not provide additional info.
    SUMMARY: AddressSanitizer: SEGV in __GI_strlen
    ABORTING

After reading a complete status line with terminal CRLF, the parser attempts to read the next header line. Since the parser does not see a CRLF from the beginning of the header line yet, it gets a nullptr from `readLine`. Constructing a `StringPiece` from a `nullptr` is a segfault.

Reviewed By: andrewjcg

Differential Revision: D4582453

fbshipit-source-id: 82a21ed6e23083f903e8a2fbf93be01ad149c4ee
facebook-github-bot pushed a commit that referenced this pull request Jun 8, 2018
Summary:
Exposed by UBSAN:
```lang=bash
thrift/compiler/generate/t_json_generator.cc:278:25: runtime error: downcast of address 0x610000000a40 which does not point to an object of type 't_set'
0x610000000a40: note: object is of type '6t_list'
 03 00 80 34  28 b9 74 8a 5f 7f 00 00  58 0a 00 00 00 61 00 00  00 00 00 00 00 00 00 00  00 be be be
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for '6t_list'
    #0 0x7f5f8b1ec21d in t_json_generator::type_to_spec_args[abi:cxx11](t_type*) thrift/compiler/generate/t_json_generator.cc:278
    #1 0x7f5f8b1ece84 in t_json_generator::print_type(t_type*) thrift/compiler/generate/t_json_generator.cc:293
    #2 0x7f5f8b1f3de0 in t_json_generator::generate_struct(t_struct*) thrift/compiler/generate/t_json_generator.cc:484
    #3 0x7f5f8b1e66aa in t_json_generator::generate_program() thrift/compiler/generate/t_json_generator.cc:161
    #4 0x42ee58 in generate(t_program*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<cha
r, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::
basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) thrift/compiler/main.cc:305
    #5 0x42b88e in main thrift/compiler/main.cc:681
    #6 0x7f5f8734b857 in __libc_start_main /home/engshare/third-party2/glibc/2.23/src/glibc-2.23/csu/../csu/libc-start.c:289
    #7 0x425a28 in _start /home/engshare/third-party2/glibc/2.23/src/glibc-2.23/csu/../sysdeps/x86_64/start.S:118

UndefinedBehaviorSanitizer: dynamic-type-mismatch thrift/compiler/generate/t_json_generator.cc:278:25
```
The fix is inspired by https://github.com/apache/thrift/pull/1222/files

Reviewed By: yfeldblum

Differential Revision: D8154131

fbshipit-source-id: 0ff7d993b87c0fe20652865a89a2bb205dde10e3
facebook-github-bot pushed a commit that referenced this pull request Aug 20, 2018
…(attempt #2)

Summary:
While attaching a read callback in `Cpp2Channel`, the read callback may fire
immediately, which in turn may lead to the transport being closed. If the
transport is no longer good after attaching the read callback, throw so that
`Cpp2Channel` does not proceed to use the transport assuming that it's still
good.

The first version of this diff had a bug: it is possible that `transport_` is
stolen during the `attachReadCallback()` call, so we need to check it's
non-null before checking `good()`.

Reviewed By: yfeldblum

Differential Revision: D9311064

fbshipit-source-id: ac15399e531e618c102cc7b59d44bb921cfbb5e9
facebook-github-bot pushed a commit that referenced this pull request Apr 10, 2019
…t (attempt #2)

Summary:
The file descriptor API here needs to go away, so switch this API to NetworkSocket

It is expected that this commit will cause a number of Open Source projects to temporarily show up as broken. This is due to the fact that not all projects get synced to Github at the exact same time, so the builds may temporarily be fetching an older version of it's dependencies than it needs to :) It should fix itself quickly.

Reviewed By: yfeldblum

Differential Revision: D14673328

fbshipit-source-id: c5842fa5dc383d50043e0d8228e35d03b10a1c6b
facebook-github-bot pushed a commit that referenced this pull request May 24, 2019
Summary: Clean up rocket client code involving the old `RocketClientFlowable` low-level API.

Reviewed By: rhodo

Differential Revision: D15494257

fbshipit-source-id: 8b7b8814dc4bcab962ef7ae6200c1f9896102b70
facebook-github-bot pushed a commit that referenced this pull request Feb 12, 2020
Summary:
Using the keyword java.swift.type in a thrift IDL,  java-swift codegen will generate Custom types.  This diff is apart of the changes that remove reflection done by swift-codec. These custom types will replace the types in the read0 and write0 methods which serialize and deserialize the data.

```
struct TypeRemapped {
  1: map<i64, string>
  (java.swift.type =
  "it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap<String>") lsMap,
 2: binary (java.swift.type = "java.nio.ByteBuffer" ) byteBufferForBinary,
}
```

Example #1: The map<i64, string> (Hashmap) will be replaced by Long2ObjectArrayMap
Example #2:  binary will be replaced by ByteBuffer.

Reviewed By: stevegury

Differential Revision: D19465263

fbshipit-source-id: e388f561105de7d862962243c9d590cdc4a8a297
facebook-github-bot pushed a commit that referenced this pull request Mar 22, 2021
Summary:
This fixes a bug where the constructor for a typedef struct isn't generated.

Attempt #2 from D26739218 (8ff51fe) which had to be reverted. This covers the union case.

Reviewed By: dlespiau

Differential Revision: D27235978

fbshipit-source-id: d3b69d0ffc5210feb32f98e76c3b567ce90b78ab
facebook-github-bot pushed a commit that referenced this pull request Aug 5, 2021
Summary:
`AsyncTransport::UniquePtr` is a resource managing type that manages the lifetime
of the underlying socket. It is declared as a member variable of `RocketServerConnection`,
which means that the implicit object destructor, which runs after the user defined `RocketServerConnection::~RocketServerConnection`,
will take care of destroying the object.

Manually destroying the object in the user defined destructor is not only unnecessary, it is incorrect. In particular, `ThriftRocketServerHandler::frameHandler_` borrows the socket_ via a raw pointer. `frameHandler_` is declared after the `socket_`, so under normal destruction ordering this borrow is valid. However, due to the fact that `~RocketServerConnection` manually destroys this, it is possible to end up with a use after free:

```
(gdb) bt
#0  0x00007f8c1f6574b8 in folly::DecoratedAsyncTransportWrapper<folly::AsyncTransport>::getPeerCertificate() const () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#1  0x00007f8c11146b4e in apache::thrift::Cpp2ConnContext::getPeerCommonName[abi:cxx11]() const () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/CppServerWrapper.so
#2  0x00007f8c1114690b in apache::thrift::CppContextData::copyContextContents(apache::thrift::Cpp2ConnContext*) () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/CppServerWrapper.so
#3  0x00007f8c1114c2d1 in CppServerEventHandler::callPythonHandler(apache::thrift::server::TConnectionContext*, char const*) () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/CppServerWrapper.so
#4  0x00007f8c1f6684b5 in apache::thrift::rocket::ThriftRocketServerHandler::~ThriftRocketServerHandler() () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#5  0x00007f8c1f972937 in non-virtual thunk to apache::thrift::rocket::RocketServerConnection::~RocketServerConnection() () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#6  0x00007f8c1f97a4fe in apache::thrift::rocket::RocketServerConnection::WriteBatcher::runLoopCallback() () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#7  0x00007f8c202d6f45 in folly::EventBase::loopBody(int, bool) () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#8  0x00007f8c202d81ed in folly::EventBase::loopForever() () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#9  0x00007f8c2026abe4 in folly::IOThreadPoolExecutor::threadRun(std::shared_ptr<folly::ThreadPoolExecutor::Thread>) () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#10 0x00007f8c202d2c74 in void std::_Bind<void (folly::ThreadPoolExecutor::*(folly::ThreadPoolExecutor*, std::shared_ptr<folly::ThreadPoolExecutor::Thread>))(std::shared_ptr<folly::ThreadPoolExecutor::Thread>)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#11 0x00007f8c202d2bc4 in void folly::detail::function::FunctionTraits<void ()>::callBig<std::_Bind<void (folly::ThreadPoolExecutor::*(folly::ThreadPoolExecutor*, std::shared_ptr<folly::ThreadPoolExecutor::Thread>))(std::shared_ptr<folly::ThreadPoolExecutor::Thread>)> >(folly::detail::function::Data&) () from /data/users/mingtao/tmp/thrift_getx509_coredump/par_unpack/sos/libomnibus.so
#12 0x00007f8c84002801 in std::execute_native_thread_routine (__p=0x7f8bfd03aee0) at ../../../.././libstdc++-v3/src/c++11/thread.cc:80
#13 0x00007f8c844ac20c in start_thread (arg=0x7f8bd6dff700) at pthread_create.c:479
#14 0x00007f8c8428881f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
```

This diff removes the manual socket reset in `RocketServerHandler` and replaces it with an explicit call to `socket->closeNow()`.

Reviewed By: andriigrynenko

Differential Revision: D30074941

fbshipit-source-id: af9ea2386cf864683eb843a8c1ca0128d7d8e467
facebook-github-bot pushed a commit that referenced this pull request Apr 18, 2022
Summary:
Fix `TMemoryBuffer::ensureCanWrite` for the empty buffer. Previously there was a UB because null pointer wasn't handled properly:

```
thrift/lib/cpp/transport/TBufferTransports.cpp:458:10: runtime error: applying non-zero offset 107271103209344 to null pointer
    #0 0x7f90a738cc31 in apache::thrift::transport::TMemoryBuffer::ensureCanWrite(unsigned int) thrift/lib/cpp/transport/TBufferTransports.cpp:458
    #1 0x7f90a7769b4e in apache::thrift::transport::TMemoryBuffer::getWritePtr(unsigned int) thrift/lib/cpp/transport/TBufferTransports.h:809
    #2 0x7f90a7769ae0 in apache::thrift::async::detail::TFramedACReadState::getReadBuffer(void**, unsigned long*) thrift/lib/cpp/async/TFramedAsyncChannel.cpp:
86
    #3 0x30909b in apache::thrift::async::TStreamAsyncChannel<apache::thrift::async::detail::TFramedACWriteRequest, apache::thrift::async::detail::TFramedACRea
dState>::getReadBuffer(void**, unsigned long*) thrift/lib/cpp/async/TStreamAsyncChannel-inl.h:260
    #4 0x7f90a767028d in folly::AsyncSocket::prepareReadBuffer(void**, unsigned long*) folly/io/async/AsyncSocket.cpp:2517
    #5 0x7f90a7677cf2 in folly::AsyncSocket::processNormalRead() folly/io/async/AsyncSocket.cpp:2869
    #6 0x7f90a767a1f4 in folly::AsyncSocket::handleRead() folly/io/async/AsyncSocket.cpp:2977
    #7 0x7f90a766d89a in folly::AsyncSocket::ioReady(unsigned short) folly/io/async/AsyncSocket.cpp:2398
    #8 0x7f90a76a442a in folly::AsyncSocket::IoHandler::handlerReady(unsigned short) folly/io/async/AsyncSocket.h:1294
    #9 0x7f90a75998d3 in folly::EventHandler::libeventCallback(int, short, void*) folly/io/async/EventHandler.cpp:159
    #10 0x7f90a6943608 in event_process_active /home/engshare/third-party2/libevent/1.4.14b_hphp/src/libevent-1.4.14b-stable/event.c:390:5
    #11 0x7f90a6943608 in event_base_loop /home/engshare/third-party2/libevent/1.4.14b_hphp/src/libevent-1.4.14b-stable/event.c:532:4
    #12 0x7f90a754aa23 in (anonymous namespace)::EventBaseBackend::eb_event_base_loop(int) folly/io/async/EventBase.cpp:74
    #13 0x7f90a7538e16 in folly::EventBase::loopBody(int, bool) folly/io/async/EventBase.cpp:381
    #14 0x7f90a75377f2 in folly::EventBase::loop() folly/io/async/EventBase.cpp:305
    #15 0x33722c in SocketPairTest<apache::thrift::async::TFramedAsyncChannel>::loop(unsigned int) thrift/lib/cpp/test/TAsyncChannelTest.cpp:506
    #16 0x3043a3 in SocketPairTest<apache::thrift::async::TFramedAsyncChannel>::runWithTimeout(unsigned int) thrift/lib/cpp/test/TAsyncChannelTest.cpp:513
    #17 0x3035f9 in SocketPairTest<apache::thrift::async::TFramedAsyncChannel>::run() thrift/lib/cpp/test/TAsyncChannelTest.cpp:509
    #18 0x2f6766 in TAsyncChannelTest_TestMultiSendRecvFramedQueued_Test::TestBody() thrift/lib/cpp/test/TAsyncChannelTest.cpp:729
    #19 0x7f90a6cc9fbf in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char c
onst*) /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2607:27
    #20 0x7f90a6cc9fbf in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char cons
t*) /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2643:52
    #21 0x7f90a6cb9ad5 in testing::Test::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2682:50
    #22 0x7f90a6cb9ad5 in testing::Test::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2672:6
    #23 0x7f90a6cb9c64 in testing::TestInfo::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2861:14
    #24 0x7f90a6cb9c64 in testing::TestInfo::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2833:6
    #25 0x7f90a6cba321 in testing::TestSuite::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:3015:31
    #26 0x7f90a6cba321 in testing::TestSuite::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2993:6
    #27 0x7f90a6cbab1e in testing::internal::UnitTestImpl::RunAllTests() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:5
855:47
    #28 0x7f90a6cb9d2c in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl
*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2607:27
    #29 0x7f90a6cb9d2c in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*,
bool (testing::internal::UnitTestImpl::*)(), char const*) /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:2643:52
    #30 0x7f90a6cb9d2c in testing::UnitTest::Run() /home/engshare/third-party2/googletest/1.11.0/src/googletest/googletest/src/gtest.cc:5438:55
    #31 0x7f90a75dbae0 in RUN_ALL_TESTS() third-party-buck/platform010/build/googletest/include/gtest/gtest.h:2490
    #32 0x7f90a75db758 in main common/gtest/LightMain.cpp:20
    #33 0x7f90a4e9b656 in __libc_start_call_main /home/engshare/third-party2/glibc/2.34/src/glibc-2.34/csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #34 0x7f90a4e9b717 in __libc_start_main_impl /home/engshare/third-party2/glibc/2.34/src/glibc-2.34/csu/../csu/libc-start.c:409:3
    #35 0x2ecbe0 in _start /home/engshare/third-party2/glibc/2.34/src/glibc-2.34/csu/../sysdeps/x86_64/start.S:116
```

Reviewed By: iahs

Differential Revision: D35723595

fbshipit-source-id: 3b0f3104a0e4551a94fcb45f2ccadcca85b699cd
facebook-github-bot pushed a commit that referenced this pull request Apr 21, 2023
…t error definitions

Summary:
It'd be helpful to be able to call `.source()` on a Thrift client error, as that would make writing dynamic retry policies far easier and allow them to be used for multiple Thrift client methods. Normally to enable this, we just need to add the `#[source]` attribute (from thiserror) to the inner value of our error enums. But this results in bad error chaining and duplicated error messages when printing out the error chain (say with `anyhow`).

I think the best solution here is to take a page out of [anyhow](https://docs.rs/anyhow/latest/anyhow/)'s book, specifically the `{:#}` semantics for `Display`. This way, we can omit printing the cause when printing with `{}` (and thus avoiding duplicate error messages when printing with `anyhow`), but one can choose to retain the behavior from before with `{:#}`.

Aside from this, there's also a few cleanups we need to do with how Thrift client errors are laid out to support `.source()`, mainly:
1. Add `#[derive(thiserror::Error)]` to `ApplicationException`
2. This then requires us to remove the `impl From<ApplicationException> for Error` in `errors.rs` as it conflicts with `anyhow`'s existing blanket impl of `From<T: std::error::Error>`
3. Removing #2 causes issues in `unionimpl.mustache` which does rely on that impl. However, `unionimpl`'s usage just returns a `ProtocolError` that wraps an `ApplicationException` that has a `ProtocolError` as an error code... so just flatten that to a new `ProtocolError` variant
4. It appears that this `unionimpl` was the only time we used the `ProtocolError::ApplicationException` variant, so just remove that. Feels weird to wrap an `ApplicationException` inside of a `ProtocolError` anyways.

inspired by https://sabrinajewson.org/blog/errors#guidelines-for-good-errors.

Reviewed By: edward-shen

Differential Revision: D44808129

fbshipit-source-id: 051c4c499bc2aa309e6319e6da59ffb3788a55a3
facebook-github-bot pushed a commit that referenced this pull request May 5, 2023
Summary:
Generated C++ Thrift code uses method names in a couple formats:
1. `<service name>.[<interaction name>.]<method name>` when configuring context
stacks, both on the [client](https://github.com/facebook/fbthrift/blob/5d86ee0072e56c64bfba8061e0f790fd3f17e362/thrift/compiler/generate/templates/cpp2/service_async_client_cpp/function_implementation.mustache#L85-L89) and the [server](https://github.com/facebook/fbthrift/blob/5d86ee0072e56c64bfba8061e0f790fd3f17e362/thrift/compiler/generate/templates/cpp2/service_tcc/process_and_return.mustache#L77).
2. [`[<interaction name>.]<method name>`](https://github.com/facebook/fbthrift/blob/5d86ee0072e56c64bfba8061e0f790fd3f17e362/thrift/compiler/generate/templates/cpp2/common/function_name.mustache#L17) for the [response envelope](https://github.com/facebook/fbthrift/blob/5d86ee0072e56c64bfba8061e0f790fd3f17e362/thrift/compiler/generate/templates/cpp2/service_tcc/process_and_return.mustache#L293) (if
applicable), the [read hook](https://github.com/facebook/fbthrift/blob/5d86ee0072e56c64bfba8061e0f790fd3f17e362/thrift/compiler/generate/templates/cpp2/service_tcc/process_and_return.mustache#L82), and the [write hook](https://github.com/facebook/fbthrift/blob/5d86ee0072e56c64bfba8061e0f790fd3f17e362/thrift/compiler/generate/templates/cpp2/service_tcc/process_and_return.mustache#L231).

Currently, Rust uses `<interaction name or service name>.<method name>` for both
of the above. The decision to use the interaction name or service name is based
on whether the method is part of an interaction - if it is, the interaction name
is used, otherwise the service name is used.

This diff updates Rust to be consistent with C++ in #1 and #2.

Reviewed By: jsgf

Differential Revision: D45322484

fbshipit-source-id: 38e2604921e69208cdcb983e8def71954b212b41
vkill pushed a commit to bk-rs/fbthrift-git-rs that referenced this pull request Dec 3, 2023
…t error definitions

Summary:
It'd be helpful to be able to call `.source()` on a Thrift client error, as that would make writing dynamic retry policies far easier and allow them to be used for multiple Thrift client methods. Normally to enable this, we just need to add the `#[source]` attribute (from thiserror) to the inner value of our error enums. But this results in bad error chaining and duplicated error messages when printing out the error chain (say with `anyhow`).

I think the best solution here is to take a page out of [anyhow](https://docs.rs/anyhow/latest/anyhow/)'s book, specifically the `{:#}` semantics for `Display`. This way, we can omit printing the cause when printing with `{}` (and thus avoiding duplicate error messages when printing with `anyhow`), but one can choose to retain the behavior from before with `{:#}`.

Aside from this, there's also a few cleanups we need to do with how Thrift client errors are laid out to support `.source()`, mainly:
1. Add `#[derive(thiserror::Error)]` to `ApplicationException`
2. This then requires us to remove the `impl From<ApplicationException> for Error` in `errors.rs` as it conflicts with `anyhow`'s existing blanket impl of `From<T: std::error::Error>`
3. Removing facebook#2 causes issues in `unionimpl.mustache` which does rely on that impl. However, `unionimpl`'s usage just returns a `ProtocolError` that wraps an `ApplicationException` that has a `ProtocolError` as an error code... so just flatten that to a new `ProtocolError` variant
4. It appears that this `unionimpl` was the only time we used the `ProtocolError::ApplicationException` variant, so just remove that. Feels weird to wrap an `ApplicationException` inside of a `ProtocolError` anyways.

inspired by https://sabrinajewson.org/blog/errors#guidelines-for-good-errors.

Reviewed By: edward-shen

Differential Revision: D44808129

fbshipit-source-id: 051c4c499bc2aa309e6319e6da59ffb3788a55a3
facebook-github-bot pushed a commit that referenced this pull request Jan 29, 2024
Summary:
In {D53166614} and {D53166618}, we need to make either of 2 choices:

1. **Every** `thrift_library` gets a clients and services crate, regardless of whether the target contains any service definitions

2. The clients and services crates only exist if the target defines nonzero services

As far as I know, it's impossible to do #2 based on whether the target *actually* contains services in its Thrift source code, only based on whether the `thrift_library` macro call lists any service names.

https://www.internalfb.com/code/fbsource/[0fa600724c20b87b38d536611b742c8287322f75]/fbcode/zippydb/if/TARGETS?lines=9-16%2C32-34%2C46

So far for Rust we have not paid attention to the listed service names in the Buck target, but the other languages look at it for a similar purpose as this.

On the basis that only 1252 out of 6042 Thrift targets in fbcode today contain services, I think limiting the clients and services crates is the right call to keep the Buck graph small. We can revisit down the line if there is any reason this turns out to be annoying.

This diff eliminates the `client` and `server` modules of Thrift library targets that do not contain any services according to Buck. Previously these used to be either empty modules, or actually nonempty modules if there were services defined in the Thrift source code but not declared in the Buck target.

Based on check_all.sh, there are zero occurrences of Rust code importing a service from a Thrift library for which the Buck target does not declare any services.

Reviewed By: zertosh, shayne-fletcher

Differential Revision: D53189031

fbshipit-source-id: e4fa7ffee4ead76802bebbc92ad514ff1d24d3b2
facebook-github-bot pushed a commit that referenced this pull request Jul 19, 2024
Summary:
Previously, every client trait in a service inheritance chain would contain a separate `.transport()` trait method for accessing the underlying fbthrift transport (e.g. ServiceRouterChannel).

If we have `service DerivedService extends BaseService` then:

```lang=rust
pub trait BaseServiceExt<T>
where
    T: Transport,
{
    ...
    fn transport(&self) -> &T {
        &self.transport
    }
}

pub trait DerivedServiceExt<T>: BaseServiceExt<T>
where
    T: Transport,
{
    ...
    fn transport(&self) -> &T {
        self.parent.transport()
    }
}
```

This causes friction because calls to `.transport()` must be disambiguated with which of these **identical** `transport` methods they want to call.

Various forms of calling `transport`:

```lang=rust
let channel = SRChannelBuilder::from_service_name(fb, "...")
    .unwrap()
    .with_client_params(srclient::ClientParams::new().with_localhost_only(port))
    .build_channel()
    .unwrap();

let client = DerivedServiceImpl::<CompactProtocol<ServiceRouterChannel>, _>::new(channel);

// inherent method
let _ = client.transport();

// statically dispatched trait method
let _ = <BaseServiceExt<_>>::transport(&client);

// dynamically dispatched trait method
let _ = (&client as &dyn DerivedServiceExt<_>).transport();

// dynamically dispatched trait method from supertrait
let _ = (&client as &dyn BaseServiceExt<_>).transport();
let _ = <AsRef<dyn BaseServiceExt<_>>>::as_ref(&client).transport();
```

Previously, calling `.transport()` on `dyn DerivedServiceExt` would be ambiguous because there are 2 such trait methods, and `dyn DerivedServiceExt` implements both traits.

```lang=text,counterexample
error[E0034]: multiple applicable items in scope
   --> path/to/repro.rs:357:52
    |
357 |     let _ = (&client as &dyn DerivedServiceExt<_>).transport();
    |                                                    ^^^^^^^^^ multiple `transport` found
    |
note: candidate #1 is defined in the trait `DerivedServiceExt`
   --> path/to/repro.rs:2416:5
note: candidate #2 is defined in the trait `BaseServiceExt`
   --> path/to/repro.rs:913:5
help: disambiguate the method for candidate #1
    |
357 |     let _ = DerivedServiceExt::transport(&(&client as &dyn DerivedServiceExt<_>));
    |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the method for candidate #2
    |
357 |     let _ = BaseServiceExt::transport(&(&client as &dyn DerivedServiceExt<_>));
    |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This diff removes the `transport` trait method of any service that extends another service, leaving every service with exactly one `transport` method among its client trait hierarchy.

Reviewed By: diliop

Differential Revision: D59937771

fbshipit-source-id: af10081d19fa7ce3748c9aadfd9d1a50d43e35a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants