Skip to content

Instantly share code, notes, and snippets.

@jmarantz
jmarantz / gist:d22b836cee3ca203cc368553eda81ce5
Created May 22, 2018 12:26
alternate implementation of CondVar using std::condition_variable_any
class CondVar {
public:
// Note that it is not necessary to be holding an associated mutex to call signal).
// See the discussion in
// http://en.cppreference.com/w/cpp/thread/condition_variable_any/notify_one
// for more details.
void notifyOne() { condvar_.notify_one(); }
void notifyAll() { condvar_.notify_all(); };
template <class LockGuard>
void wait(LockGuard& guard) EXCLUSIVE_LOCKS_REQUIRED(guard) {
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <memory>
#include <string>
class InlineStorage {
public:
// Custom delete operator to keep C++14 from using the global operator delete(void*, size_t),
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //test/extensions/filters/http/aws_lambda:aws_lambda_filter_integration_test
-----------------------------------------------------------------------------
WARNING: Perftools heap leak checker is active -- Performance may suffer
[==========] Running 6 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 6 tests from IpVersions/AwsLambdaFilterIntegrationTest
[ RUN ] IpVersions/AwsLambdaFilterIntegrationTest.JsonWrappedHeaderOnlyRequest/IPv4
[2020-03-27 15:56:33.103][14][info][testing] [test/integration/fake_upstream.cc:398] starting fake server on socket 0.0.0.0:0. Address version is v4. UDP=false
[2020-03-27 15:56:33.103][14][debug][misc] [test/integration/integration.cc:330] Setting up file-based LDS
crashing thread:
(gdb) where
#0 0x0000000000000000 in ?? ()
#1 0x00000000020d5064 in Envoy::FakeStream::encodeHeaders(Envoy::Http::HeaderMap const&, bool)::$_1::operator()() const (this=0x5e2eea8) at test/integration/fake_upstream.cc:102
#2 0x00000000020d4fdd in std::__1::__invoke<Envoy::FakeStream::encodeHeaders(Envoy::Http::HeaderMap const&, bool)::$_1&> (__f=...)
at /usr/local/google/home/jmarantz/ext/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/../include/c++/v1/type_traits:3530
#3 0x00000000020d4f8d in std::__1::__invoke_void_return_wrapper<void>::__call<Envoy::FakeStream::encodeHeaders(Envoy::Http::HeaderMap const&, bool)::$_1&>(Envoy::FakeStream::encodeHeaders(Envoy::Http::HeaderMap const&, bool)::$_1&) (__args=...)
at /usr/local/google/home/jmarantz/ext/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/../include/c++/v1/__functional_base:348
#4 0x00000000020d4f5d in std::__1::__function::__alloc_func<Envoy::FakeStream::encodeHeaders(Envoy::Http::HeaderMap const&, bool)::$_1, std::_
[ RUN ] IpVersionsClientType/HdsIntegrationTest.SingleEndpointTimeoutHttp/0
==================
WARNING: ThreadSanitizer: heap-use-after-free (virtual call vs free) (pid=14)
Read of size 8 at 0x7b5400090338 by main thread:
#0 Envoy::Http::Legacy::Http1::ConnectionImpl::ConnectionImpl(Envoy::Network::Connection&, Envoy::Http::Http1::CodecStats&, http_parser_type, unsigned int, unsigned int, std::__1::unique_ptr<Envoy::Http::Http1::HeaderKeyFormatter, std::__1::default_delete<Envoy::Http::Http1::HeaderKeyFormatter> >&&, bool) ??:? (hds_integration_test+0x4b81c83)
#1 Envoy::Http::Legacy::Http1::ServerConnectionImpl::ServerConnectionImpl(Envoy::Network::Connection&, Envoy::Http::Http1::CodecStats&, Envoy::Http::ServerConnectionCallbacks&, Envoy::Http::Http1Settings const&, unsigned int, unsigned int, envoy::config::core::v3::HttpProtocolOptions_HeadersWithUnderscoresAction) ??:? (hds_integration_test+0x4b87143)
#2 Envoy::Legacy::TestHttp1ServerConnectionImpl::ServerConnectionImpl(Envoy::Network:
[ RUN ] IpVersionsClientType/HdsIntegrationTest.SingleEndpointTimeoutHttp/4
==================
WARNING: ThreadSanitizer: data race (pid=14)
Write of size 4 at 0x7b08000bb3e8 by thread T10:
#0 Envoy::Network::IoSocketHandleImpl::close() ??:? (hds_integration_test+0x55d3a10)
#1 Envoy::Network::SocketImpl::close() ??:? (hds_integration_test+0x2aa670a)
#2 Envoy::Network::ConnectionImpl::closeSocket(Envoy::Network::ConnectionEvent) ??:? (hds_integration_test+0x51c9e48)
#3 Envoy::Network::ConnectionImpl::onFileEvent(unsigned int) ??:? (hds_integration_test+0x51ce279)
#4 Envoy::Network::ConnectionImpl::ConnectionImpl(Envoy::Event::Dispatcher&, std::__1::unique_ptr<Envoy::Network::ConnectionSocket, std::__1::default_delete<Envoy::Network::ConnectionSocket> >&&, std::__1::unique_ptr<Envoy::Network::TransportSocket, std::__1::default_delete<Envoy::Network::TransportSocket> >&&, Envoy::StreamInfo::StreamInfo&, bool)::$_6::operator()(unsigned int) const connection_impl.cc:? (hds_integration_tes
[ RUN ] IpVersionsClientType/HdsIntegrationTest.SingleEndpointTimeoutHttp/3
==================
WARNING: ThreadSanitizer: heap-use-after-free (virtual call vs free) (pid=14)
Read of size 8 at 0x7b5400090338 by main thread:
#0 Envoy::Http::Legacy::Http1::ConnectionImpl::ConnectionImpl(Envoy::Network::Connection&, Envoy::Http::Http1::CodecStats&, http_parser_type, unsigned int, unsigned int, std::__1::unique_ptr<Envoy::Http::Http1::HeaderKeyFormatter, std::__1::default_delete<Envoy::Http::Http1::HeaderKeyFormatter> >&&, bool) ??:? (hds_integration_test+0x4bc0e13)
#1 Envoy::Http::Legacy::Http1::ServerConnectionImpl::ServerConnectionImpl(Envoy::Network::Connection&, Envoy::Http::Http1::CodecStats&, Envoy::Http::ServerConnectionCallbacks&, Envoy::Http::Http1Settings const&, unsigned int, unsigned int, envoy::config::core::v3::HttpProtocolOptions_HeadersWithUnderscoresAction) ??:? (hds_integration_test+0x4bc62d3)
#2 Envoy::Legacy::TestHttp1ServerConnectionImpl::ServerConnectionImpl(Envoy::Network:
Change by morlovich@morlovich:flake:1956:citc on 2020/01/28
Fix shared mem tests to lock properly.
Makes them a bit less bootstrap-y, but needed for correctness anyway
Index: pagespeed/kernel/sharedmem/shared_mem_test_base.ccxxxxxpagespeed/kernel/sharedmem/shared_mem_test_base.cc ====
--- /google/src/files/266908245/depot/google3pagespeed/kernel/sharedmem/shared_mem_test_base.cc 2019-09-03 08:33:36.000000000 -0400
+++ pagespeed/kernel/sharedmem/shared_mem_test_base.cc 2020-01-28 16:22:01.000000000 -0500
diff --git a/source/common/stats/thread_local_store.cc b/source/common/stats/thread_local_store.cc
index 81e968177d..73da5d1614 100644
--- a/source/common/stats/thread_local_store.cc
+++ b/source/common/stats/thread_local_store.cc
@@ -42,6 +42,7 @@ ThreadLocalStoreImpl::~ThreadLocalStoreImpl() {
ASSERT(shutting_down_ || !threading_ever_initialized_);
default_scope_.reset();
ASSERT(scopes_.empty());
+ ASSERT(histograms_to_cleanup_.empty());
}
diff --git a/include/envoy/thread_local/thread_local.h b/include/envoy/thread_local/thread_local.h
index 8ff2ca99c8..f13be54cba 100644
--- a/include/envoy/thread_local/thread_local.h
+++ b/include/envoy/thread_local/thread_local.h
@@ -226,6 +226,8 @@ public:
* @return Event::Dispatcher& the thread local dispatcher.
*/
virtual Event::Dispatcher& dispatcher() PURE;
+
+ virtual bool isShutdown() const { return false; }