Skip to content

Conversation

mattklein123
Copy link
Member

No description provided.

@mattklein123 mattklein123 deleted the ci_test branch August 10, 2016 15:36
@mattklein123 mattklein123 restored the ci_test branch August 10, 2016 15:37
@mattklein123 mattklein123 reopened this Aug 10, 2016
@mattklein123 mattklein123 changed the title tmp Initial import Aug 10, 2016
@mattklein123 mattklein123 deleted the ci_test branch August 10, 2016 21:43
@hzariv hzariv mentioned this pull request Jun 8, 2017
ggreenway pushed a commit that referenced this pull request Aug 1, 2024
When the ``AsyncTcpClient`` is being destroyed but it
also has an active client connection, there's a crash since during the
instance destruction, the ``ClientConnection`` object would also be
destroyed, causing ``raiseEvent`` to be called back to
``AsyncTcpClient`` while it is being destroyed

Caught with the following stack trace:
```
Caught Segmentation fault, suspect faulting address 0x0
Backtrace (use tools/stack_decode.py to get line numbers):
Envoy version: ee8c765a07037033766ea556c032120b497152b3/1.27.0/Clean/RELEASE/BoringSSL
#0: __restore_rt [0x7d80ab903420]
#1: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLoggerImpl::onEvent() [0x58313528746b]
#2: Envoy::Tcp::AsyncTcpClientImpl::onEvent() [0x5831359da00a]
#3: Envoy::Network::ConnectionImplBase::raiseConnectionEvent() [0x583135f0521d]
#4: Envoy::Network::ConnectionImpl::raiseEvent() [0x583135e9fed9]
#5: Envoy::Network::ConnectionImpl::closeSocket() [0x583135e9f90c]
#6: Envoy::Network::ConnectionImpl::close() [0x583135e9e54c]
#7: Envoy::Network::ConnectionImpl::~ConnectionImpl() [0x583135e9de5c]
#8: Envoy::Network::ClientConnectionImpl::~ClientConnectionImpl() [0x5831355fd25e]
#9: Envoy::Tcp::AsyncTcpClientImpl::~AsyncTcpClientImpl() [0x5831359da247]
#10: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLoggerImpl::~FluentdAccessLoggerImpl() [0x583135289350]
#11: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLog::ThreadLocalLogger::~ThreadLocalLogger() [0x58313528adbf]
#12: Envoy::ThreadLocal::InstanceImpl::shutdownThread() [0x58313560373a]
#13: Envoy::Server::WorkerImpl::threadRoutine() [0x583135630c0a]
#14: Envoy::Thread::ThreadImplPosix::ThreadImplPosix()::{lambda()#1}::__invoke() [0x5831364e88d5]
#15: start_thread [0x7d80ab8f7609]
```
Risk Level: low
Testing: unit tests
Docs Changes: none
Release Notes: none
Platform Specific Features: none

---------

Signed-off-by: Ohad Vano <ohadvano@gmail.com>
martinduke pushed a commit to martinduke/envoy that referenced this pull request Aug 8, 2024
…yproxy#35410)

When the ``AsyncTcpClient`` is being destroyed but it
also has an active client connection, there's a crash since during the
instance destruction, the ``ClientConnection`` object would also be
destroyed, causing ``raiseEvent`` to be called back to
``AsyncTcpClient`` while it is being destroyed

Caught with the following stack trace:
```
Caught Segmentation fault, suspect faulting address 0x0
Backtrace (use tools/stack_decode.py to get line numbers):
Envoy version: ee8c765a07037033766ea556c032120b497152b3/1.27.0/Clean/RELEASE/BoringSSL
#0: __restore_rt [0x7d80ab903420]
envoyproxy#1: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLoggerImpl::onEvent() [0x58313528746b]
envoyproxy#2: Envoy::Tcp::AsyncTcpClientImpl::onEvent() [0x5831359da00a]
envoyproxy#3: Envoy::Network::ConnectionImplBase::raiseConnectionEvent() [0x583135f0521d]
envoyproxy#4: Envoy::Network::ConnectionImpl::raiseEvent() [0x583135e9fed9]
envoyproxy#5: Envoy::Network::ConnectionImpl::closeSocket() [0x583135e9f90c]
envoyproxy#6: Envoy::Network::ConnectionImpl::close() [0x583135e9e54c]
envoyproxy#7: Envoy::Network::ConnectionImpl::~ConnectionImpl() [0x583135e9de5c]
envoyproxy#8: Envoy::Network::ClientConnectionImpl::~ClientConnectionImpl() [0x5831355fd25e]
envoyproxy#9: Envoy::Tcp::AsyncTcpClientImpl::~AsyncTcpClientImpl() [0x5831359da247]
envoyproxy#10: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLoggerImpl::~FluentdAccessLoggerImpl() [0x583135289350]
envoyproxy#11: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLog::ThreadLocalLogger::~ThreadLocalLogger() [0x58313528adbf]
envoyproxy#12: Envoy::ThreadLocal::InstanceImpl::shutdownThread() [0x58313560373a]
envoyproxy#13: Envoy::Server::WorkerImpl::threadRoutine() [0x583135630c0a]
envoyproxy#14: Envoy::Thread::ThreadImplPosix::ThreadImplPosix()::{lambda()envoyproxy#1}::__invoke() [0x5831364e88d5]
envoyproxy#15: start_thread [0x7d80ab8f7609]
```
Risk Level: low
Testing: unit tests
Docs Changes: none
Release Notes: none
Platform Specific Features: none

---------

Signed-off-by: Ohad Vano <ohadvano@gmail.com>
Signed-off-by: Martin Duke <martin.h.duke@gmail.com>
asingh-g pushed a commit to asingh-g/envoy that referenced this pull request Aug 20, 2024
…yproxy#35410)

When the ``AsyncTcpClient`` is being destroyed but it
also has an active client connection, there's a crash since during the
instance destruction, the ``ClientConnection`` object would also be
destroyed, causing ``raiseEvent`` to be called back to
``AsyncTcpClient`` while it is being destroyed

Caught with the following stack trace:
```
Caught Segmentation fault, suspect faulting address 0x0
Backtrace (use tools/stack_decode.py to get line numbers):
Envoy version: ee8c765a07037033766ea556c032120b497152b3/1.27.0/Clean/RELEASE/BoringSSL
#0: __restore_rt [0x7d80ab903420]
envoyproxy#1: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLoggerImpl::onEvent() [0x58313528746b]
envoyproxy#2: Envoy::Tcp::AsyncTcpClientImpl::onEvent() [0x5831359da00a]
envoyproxy#3: Envoy::Network::ConnectionImplBase::raiseConnectionEvent() [0x583135f0521d]
envoyproxy#4: Envoy::Network::ConnectionImpl::raiseEvent() [0x583135e9fed9]
envoyproxy#5: Envoy::Network::ConnectionImpl::closeSocket() [0x583135e9f90c]
envoyproxy#6: Envoy::Network::ConnectionImpl::close() [0x583135e9e54c]
envoyproxy#7: Envoy::Network::ConnectionImpl::~ConnectionImpl() [0x583135e9de5c]
envoyproxy#8: Envoy::Network::ClientConnectionImpl::~ClientConnectionImpl() [0x5831355fd25e]
envoyproxy#9: Envoy::Tcp::AsyncTcpClientImpl::~AsyncTcpClientImpl() [0x5831359da247]
envoyproxy#10: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLoggerImpl::~FluentdAccessLoggerImpl() [0x583135289350]
envoyproxy#11: Envoy::Extensions::AccessLoggers::Fluentd::FluentdAccessLog::ThreadLocalLogger::~ThreadLocalLogger() [0x58313528adbf]
envoyproxy#12: Envoy::ThreadLocal::InstanceImpl::shutdownThread() [0x58313560373a]
envoyproxy#13: Envoy::Server::WorkerImpl::threadRoutine() [0x583135630c0a]
envoyproxy#14: Envoy::Thread::ThreadImplPosix::ThreadImplPosix()::{lambda()envoyproxy#1}::__invoke() [0x5831364e88d5]
envoyproxy#15: start_thread [0x7d80ab8f7609]
```
Risk Level: low
Testing: unit tests
Docs Changes: none
Release Notes: none
Platform Specific Features: none

---------

Signed-off-by: Ohad Vano <ohadvano@gmail.com>
Signed-off-by: asingh-g <abhisinghx@google.com>
nezdolik added a commit that referenced this pull request Sep 9, 2024
Fixing asan failures:
```
==16==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x323ecbe in malloc /local/mnt/workspace/bcain_clang_hu-bcain-lv_22036/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0xa58a194 in operator new(unsigned long) (/b/f/w/bazel-out/k8-dbg/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test.runfiles/envoy/test/extensions/geoip_providers/maxmind/geoip_provider_test+0xa58a194)
    #2 0x3348d04 in void std::__1::vector<std::__1::function<absl::lts_20230802::Status (unsigned int)>, std::__1::allocator<std::__1::function<absl::lts_20230802::Status (unsigned int)> > >::__emplace_back_slow_path<std::__1::function<absl::lts_20230802::Status (unsigned int)> >(std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) /opt/llvm/bin/../include/c++/v1/vector:1558:49
    #3 0x3348883 in std::__1::function<absl::lts_20230802::Status (unsigned int)>& std::__1::vector<std::__1::function<absl::lts_20230802::Status (unsigned int)>, std::__1::allocator<std::__1::function<absl::lts_20230802::Status (unsigned int)> > >::emplace_back<std::__1::function<absl::lts_20230802::Status (unsigned int)> >(std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) /opt/llvm/bin/../include/c++/v1/vector:1580:9
    #4 0x3348554 in Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)::operator()(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>) const /proc/self/cwd/test/extensions/geoip_providers/maxmind/geoip_provider_test.cc:118:35
    #5 0x334830e in decltype(static_cast<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)&>(fp)(static_cast<std::__1::basic_string_view<char, std::__1::char_traits<char> >>(fp0), static_cast<unsigned int>(fp0), static_cast<std::__1::function<absl::lts_20230802::Status (unsigned int)>>(fp0))) std::__1::__invoke<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)&, std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> >(Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)&, std::__1::basic_string_view<char, std::__1::char_traits<char> >&&, unsigned int&&, std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) /opt/llvm/bin/../include/c++/v1/type_traits:3640:23
    #6 0x33481c5 in absl::lts_20230802::Status std::__1::__invoke_void_return_wrapper<absl::lts_20230802::Status, false>::__call<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)&, std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> >(Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)&, std::__1::basic_string_view<char, std::__1::char_traits<char> >&&, unsigned int&&, std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) /opt/llvm/bin/../include/c++/v1/__functional/invoke.h:30:16
    #7 0x334819d in std::__1::__function::__alloc_func<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>), std::__1::allocator<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>, absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::operator()(std::__1::basic_string_view<char, std::__1::char_traits<char> >&&, unsigned int&&, std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) /opt/llvm/bin/../include/c++/v1/__functional/function.h:180:16
    #8 0x3347993 in std::__1::__function::__func<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>), std::__1::allocator<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>, absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::operator()(std::__1::basic_string_view<char, std::__1::char_traits<char> >&&, unsigned int&&, std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) /opt/llvm/bin/../include/c++/v1/__functional/function.h:354:12
    #9 0x71758dd in std::__1::__function::__value_func<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::operator()(std::__1::basic_string_view<char, std::__1::char_traits<char> >&&, unsigned int&&, std::__1::function<absl::lts_20230802::Status (unsigned int)>&&) const /opt/llvm/bin/../include/c++/v1/__functional/function.h:507:16
    #10 0x7175738 in std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::operator()(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>) const /opt/llvm/bin/../include/c++/v1/__functional/function.h:1184:12
    #11 0x71754e8 in decltype(std::forward<std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&>(fp)(std::get<0ul>(std::forward<std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> > >(fp0)), std::get<1ul>(std::forward<std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> > >(fp0)), std::get<2ul>(std::forward<std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> > >(fp0)))) testing::internal::ApplyImpl<std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> >, 0ul, 1ul, 2ul>(std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> >&&, testing::internal::IndexSequence<0ul, 1ul, 2ul>) /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:420:10
    #12 0x7175395 in decltype(ApplyImpl(std::forward<std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&>(fp), std::forward<std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> > >(fp0), (testing::internal::MakeIndexSequence<std::tuple_size<std::__1::remove_reference<std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> > >::type>::value>)())) testing::internal::Apply<std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> > >(std::__1::function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> >&&) /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:429:10
    #13 0x7174d47 in testing::Action<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::Perform(std::__1::tuple<std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)> >) const /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-actions.h:497:12
    #14 0x7175afd in testing::internal::ActionResultHolder<absl::lts_20230802::Status>* testing::internal::ActionResultHolder<absl::lts_20230802::Status>::PerformAction<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>(testing::Action<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)> const&, testing::internal::Function<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::ArgumentTuple&&) /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:1402:24
    #15 0x7173651 in testing::internal::FunctionMocker<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::UntypedPerformAction(void const*, void*) const /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:1556:12
    #16 0xa3e9535 in testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*) /proc/self/cwd/external/com_google_googletest/googlemock/src/gmock-spec-builders.cc:452:24
    #17 0x333e5b2 in testing::internal::FunctionMocker<absl::lts_20230802::Status (std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>)>::Invoke(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>) /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:1593:15
    #18 0x333e24c in Envoy::Filesystem::MockWatcher::addWatch(std::__1::basic_string_view<char, std::__1::char_traits<char> >, unsigned int, std::__1::function<absl::lts_20230802::Status (unsigned int)>) /proc/self/cwd/./test/mocks/filesystem/mocks.h:78:3
    #19 0x3405db9 in decltype(static_cast<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::__1::shared_ptr<Envoy::Singleton::Instance>, std::__1::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0&>(fp)()) std::__1::__invoke<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::__1::shared_ptr<Envoy::Singleton::Instance>, std::__1::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0&>(Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::__1::shared_ptr<Envoy::Singleton::Instance>, std::__1::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0&) /proc/self/cwd/source/extensions/geoip_providers/maxmind/geoip_provider.cc:126:11
    #20 0x3404a63 in std::__1::__function::__func<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::__1::shared_ptr<Envoy::Singleton::Instance>, std::__1::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0, std::__1::allocator<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::__1::shared_ptr<Envoy::Singleton::Instance>, std::__1::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0>, void ()>::operator()() /opt/llvm/bin/../include/c++/v1/__functional/invoke.h:61:9
    #21 0x34f0239 in std::__1::__function::__value_func<void ()>::operator()() const /opt/llvm/bin/../include/c++/v1/__functional/function.h:507:16
    #22 0x91dbf37 in Envoy::Thread::PosixThreadFactory::createPthread(Envoy::Thread::ThreadHandle*)::$_6::__invoke(void*) /opt/llvm/bin/../include/c++/v1/__functional/function.h:1184:12
    #23 0x7fb0ecf9f608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x8608) (BuildId: 0c044ba611aeeeaebb8374e660061f341ebc0bac)
```

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
Fixes #35829
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: Kateryna Nezdolii <kateryna.nezdolii@gmail.com>
ravenblackx pushed a commit that referenced this pull request Sep 23, 2024
Fix for:
```
==12==ERROR: AddressSanitizer: heap-use-after-free on address 0x60300019d860 at pc 0xb7d3f059f8cc bp 0xe6dc6a8fde80 sp 0xe6dc6a8fd670
WRITE of size 24 at 0x60300019d860 thread T1
    #0 0xb7d3f059f8c8 in __asan_memset (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x48ef8c8)
    #1 0xb7d3f065bb9c in std::function<absl::lts_20230802::Status (unsigned int)>& std::vector<std::function<absl::lts_20230802::Status (unsigned int)>, std::allocator<std::function<absl::lts_20230802::Status (unsigned int)>>>::emplace_back<std::function<absl::lts_20230802::Status (unsigned int)>>(std::function<absl::lts_20230802::Status (unsigned int)>&&) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49abb9c)
    #2 0xb7d3f065b6a0 in Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)::operator()(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>) const (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49ab6a0)
    #3 0xb7d3f065b2c0 in std::_Function_handler<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>), Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::_M_invoke(std::_Any_data const&, std::basic_string_view<char, std::char_traits<char>>&&, unsigned int&&, std::function<absl::lts_20230802::Status (unsigned int)>&&) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49ab2c0)
    #4 0xb7d3f3080050 in decltype(std::forward<std::function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&>(fp)(std::get<0ul>(std::forward<std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>>(fp0)), std::get<1ul>(std::forward<std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>>(fp0)), std::get<2ul>(std::forward<std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>>(fp0)))) testing::internal::ApplyImpl<std::function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>, 0ul, 1ul, 2ul>(std::function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>&&, testing::internal::IndexSequence<0ul, 1ul, 2ul>) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x73d0050)
    #5 0xb7d3f3080438 in testing::internal::ActionResultHolder<absl::lts_20230802::Status>* testing::internal::ActionResultHolder<absl::lts_20230802::Status>::PerformAction<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>(testing::Action<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&, testing::internal::Function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::ArgumentTuple&&) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x73d0438)
    #6 0xb7d3f307e148 in testing::internal::FunctionMocker<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::UntypedPerformAction(void const*, void*) const (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x73ce148)
    #7 0xb7d3f531993c in testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x966993c)
    #8 0xb7d3f0657fa0 in testing::internal::FunctionMocker<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::Invoke(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49a7fa0)
    #9 0xb7d3f0657c2c in Envoy::Filesystem::MockWatcher::addWatch(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49a7c2c)
    #10 0xb7d3f06b63b4 in std::_Function_handler<void (), Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::shared_ptr<Envoy::Singleton::Instance>, std::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0>::_M_invoke(std::_Any_data const&) geoip_provider.cc
    #11 0xb7d3f45c9fc8 in Envoy::Thread::PosixThreadFactory::createPthread(Envoy::Thread::ThreadHandle*)::$_0::__invoke(void*) thread_impl.cc
    #12 0xe6dc6ea637cc  (/lib/aarch64-linux-gnu/libc.so.6+0x837cc) (BuildId: 5b12268cafe96b30a4b950adece623b540b747be)
    #13 0xe6dc6eacf5c8  (/lib/aarch64-linux-gnu/libc.so.6+0xef5c8) (BuildId: 5b12268cafe96b30a4b950adece623b540b747be)

0x60300019d860 is located 0 bytes inside of 32-byte region [0x60300019d860,0x60300019d880)
freed by thread T0 here:
    #0 0xb7d3f05a0138 in free (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x48f0138)
    #1 0xb7d3f05edd2c in std::vector<std::function<absl::lts_20230802::Status (unsigned int)>, std::allocator<std::function<absl::lts_20230802::Status (unsigned int)>>>::~vector() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x493dd2c)
    #2 0xb7d3f0648504 in Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::~GeoipProviderTestBase() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x4998504)
    #3 0xb7d3f05eba10 in Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTest_ValidConfigCityAndIspDbsSuccessfulLookup_Test::~GeoipProviderTest_ValidConfigCityAndIspDbsSuccessfulLookup_Test() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x493ba10)
    #4 0xb7d3f53a68b0 in testing::Test::DeleteSelf_() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96f68b0)
    #5 0xb7d3f53a5ccc in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96f5ccc)
    #6 0xb7d3f53702fc in testing::TestInfo::Run() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96c02fc)
    #7 0xb7d3f5371dc8 in testing::TestSuite::Run() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96c1dc8)
    #8 0xb7d3f5394e84 in testing::internal::UnitTestImpl::RunAllTests() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96e4e84)
    #9 0xb7d3f53a82a4 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96f82a4)
    #10 0xb7d3f53945d0 in testing::UnitTest::Run() (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x96e45d0)
    #11 0xb7d3f2f2ea10 in Envoy::TestRunner::runTests(int, char**) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x727ea10)
    #12 0xb7d3f2f2b2c0 in main (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x727b2c0)
    #13 0xe6dc6ea07580  (/lib/aarch64-linux-gnu/libc.so.6+0x27580) (BuildId: 5b12268cafe96b30a4b950adece623b540b747be)
    #14 0xe6dc6ea07654 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27654) (BuildId: 5b12268cafe96b30a4b950adece623b540b747be)
    #15 0xb7d3f0502eec in _start (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x4852eec)

previously allocated by thread T1 here:
    #0 0xb7d3f05a03cc in malloc (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x48f03cc)
    #1 0xb7d3f5428378 in operator new(unsigned long) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x9778378)
    #2 0xb7d3f065b994 in std::vector<std::function<absl::lts_20230802::Status (unsigned int)>, std::allocator<std::function<absl::lts_20230802::Status (unsigned int)>>>::reserve(unsigned long) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49ab994)
    #3 0xb7d3f065b684 in Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)::operator()(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>) const (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49ab684)
    #4 0xb7d3f065b2c0 in std::_Function_handler<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>), Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::optional<Envoy::ConditionalInitializer>&)::'lambda'()::operator()() const::'lambda'(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::_M_invoke(std::_Any_data const&, std::basic_string_view<char, std::char_traits<char>>&&, unsigned int&&, std::function<absl::lts_20230802::Status (unsigned int)>&&) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49ab2c0)
    #5 0xb7d3f3080050 in decltype(std::forward<std::function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&>(fp)(std::get<0ul>(std::forward<std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>>(fp0)), std::get<1ul>(std::forward<std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>>(fp0)), std::get<2ul>(std::forward<std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>>(fp0)))) testing::internal::ApplyImpl<std::function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>, 0ul, 1ul, 2ul>(std::function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&, std::tuple<std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>>&&, testing::internal::IndexSequence<0ul, 1ul, 2ul>) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x73d0050)
    #6 0xb7d3f3080438 in testing::internal::ActionResultHolder<absl::lts_20230802::Status>* testing::internal::ActionResultHolder<absl::lts_20230802::Status>::PerformAction<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>(testing::Action<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)> const&, testing::internal::Function<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::ArgumentTuple&&) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x73d0438)
    #7 0xb7d3f307e148 in testing::internal::FunctionMocker<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::UntypedPerformAction(void const*, void*) const (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x73ce148)
    #8 0xb7d3f531993c in testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x966993c)
    #9 0xb7d3f0657fa0 in testing::internal::FunctionMocker<absl::lts_20230802::Status (std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>)>::Invoke(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49a7fa0)
    #10 0xb7d3f0657c2c in Envoy::Filesystem::MockWatcher::addWatch(std::basic_string_view<char, std::char_traits<char>>, unsigned int, std::function<absl::lts_20230802::Status (unsigned int)>) (/home/nezdolik.linux/.cache/bazel/_bazel_nezdolik/9a5f062d7ba021dba530b9f40b2998a7/execroot/envoy/bazel-out/aarch64-fastbuild/bin/test/extensions/geoip_providers/maxmind/geoip_provider_test+0x49a7c2c)
    #11 0xb7d3f06b61d4 in std::_Function_handler<void (), Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::shared_ptr<Envoy::Singleton::Instance>, std::shared_ptr<Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderConfig>)::$_0>::_M_invoke(std::_Any_data const&) geoip_provider.cc
    #12 0xb7d3f45c9fc8 in Envoy::Thread::PosixThreadFactory::createPthread(Envoy::Thread::ThreadHandle*)::$_0::__invoke(void*) thread_impl.cc
    #13 0xe6dc6ea637cc  (/lib/aarch64-linux-gnu/libc.so.6+0x837cc) (BuildId: 5b12268cafe96b30a4b950adece623b540b747be)
    #14 0xe6dc6eacf5c8  (/lib/aarch64-linux-gnu/libc.so.6+0xef5c8) (BuildId: 5b12268cafe96b30a4b950adece623b540b747be)
```

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: Kateryna Nezdolii <kateryna.nezdolii@gmail.com>
yanavlasov pushed a commit that referenced this pull request Jan 28, 2025
Commit Message: Add stacktrace to ASSERTs
Additional Description: Before this change, ASSERTs provoke a
stacktrace, but it is always the useless two-line stacktrace
```
#0: sigHandler()
#1: restore_rt
```
as demonstrated by the test case added in this PR not passing before the
change.
It's a bit odd that after this change there will be two stacktraces
output on assert, but at least one of them will be useful.

Risk Level: Minimal, it's just output from asserts so if it does
anything it's during a crash anyway.
Testing: Added a test case, and used to debug my production issue which
I couldn't with the original version.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

---------

Signed-off-by: Raven Black <ravenblack@dropbox.com>
phlax pushed a commit that referenced this pull request Apr 22, 2025
When trying to build and run fuzzers that may throw an exception (e.g.,
`bazel build //test/common/http:path_utility_fuzz_test
--config=asan-fuzzer`) the following error occurs:
```
$ bazel-bin/test/common/http/path_utility_fuzz_test /tmp/corpus
INFO: found LLVMFuzzerCustomMutator (0x555ec3b27058). Disabling -len_control by default.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3031084950
INFO: Loaded 1 modules   (2436830 inline 8-bit counters): 2436830 [0x555ecf049c40, 0x555ecf29cb1e),
INFO: Loaded 1 PC tables (2436830 PCs): 2436830 [0x555ecf29cb20,0x555ed17cb900),
INFO:        5 files found in /tmp/corpus
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 5 min: 91b max: 332b total: 1208b rss: 357Mb
libc++abi: terminating due to uncaught exception of type Envoy::EnvoyException
==3072858== ERROR: libFuzzer: deadly signal
    #0 0x555ec3ae0911 in __sanitizer_print_stack_trace (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa49f911)
    #1 0x555ec39e56b8 in fuzzer::PrintStackTrace() cxa_noexception.cpp
    #2 0x555ec39c8a53 in fuzzer::Fuzzer::CrashCallback() cxa_noexception.cpp
    #3 0x7f5506763e1f  (/lib/x86_64-linux-gnu/libc.so.6+0x3fe1f) (BuildId: ea119b374e0f8f858c82ad03a9542414f9ea1c8c)
    #4 0x7f55067b7e5b in __pthread_kill_implementation nptl/pthread_kill.c:43:17
    #5 0x7f5506763d81 in raise signal/../sysdeps/posix/raise.c:26:13
    #6 0x7f550674c4ef in abort stdlib/abort.c:79:7
    #7 0x555ecc751905 in abort_message abort_message.cpp
    #8 0x555ecc751ae2 in demangling_terminate_handler() cxa_default_handlers.cpp
    #9 0x555ecc7519a2 in std::__terminate(void (*)()) cxa_handlers.cpp
    #10 0x555ecc750fd5 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) cxa_exception.cpp
    #11 0x555ecc750fbf in __cxa_throw (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x1310ffbf)
    #12 0x555ec97f5a1f in Envoy::ProtoExceptionUtil::throwProtoValidationException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, google::protobuf::Message const&) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x101b4a1f)
    #13 0x555ec3b87a1c in void Envoy::MessageUtil::validate<test::common::http::PathUtilityTestCase>(test::common::http::PathUtilityTestCase const&, Envoy::ProtobufMessage::ValidationVisitor&, bool) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa546a1c)
    #14 0x555ec3b277be in LLVMFuzzerTestOneInput (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa4e67be)
    #15 0x555ec39c9f60 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) cxa_noexception.cpp
    #16 0x555ec39c9785 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) cxa_noexception.cpp
    #17 0x555ec39cb712 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    #18 0x555ec39cba02 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    #19 0x555ec39b9eeb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) cxa_noexception.cpp
    #20 0x555ec39e5f12 in main (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa3a4f12)
    #21 0x7f550674dd67 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #22 0x7f550674de24 in __libc_start_main csu/../csu/libc-start.c:360:3
    #23 0x555ec39ac720 in _start (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa36b720)

NOTE: libFuzzer has rudimentary signal handlers.
      Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
```

This PR adds a linking flag to allow the fuzzers to properly handle
exceptions.

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
oconnorkyle pushed a commit to oconnorkyle/envoy that referenced this pull request Apr 23, 2025
When trying to build and run fuzzers that may throw an exception (e.g.,
`bazel build //test/common/http:path_utility_fuzz_test
--config=asan-fuzzer`) the following error occurs:
```
$ bazel-bin/test/common/http/path_utility_fuzz_test /tmp/corpus
INFO: found LLVMFuzzerCustomMutator (0x555ec3b27058). Disabling -len_control by default.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3031084950
INFO: Loaded 1 modules   (2436830 inline 8-bit counters): 2436830 [0x555ecf049c40, 0x555ecf29cb1e),
INFO: Loaded 1 PC tables (2436830 PCs): 2436830 [0x555ecf29cb20,0x555ed17cb900),
INFO:        5 files found in /tmp/corpus
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 5 min: 91b max: 332b total: 1208b rss: 357Mb
libc++abi: terminating due to uncaught exception of type Envoy::EnvoyException
==3072858== ERROR: libFuzzer: deadly signal
    #0 0x555ec3ae0911 in __sanitizer_print_stack_trace (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa49f911)
    envoyproxy#1 0x555ec39e56b8 in fuzzer::PrintStackTrace() cxa_noexception.cpp
    envoyproxy#2 0x555ec39c8a53 in fuzzer::Fuzzer::CrashCallback() cxa_noexception.cpp
    envoyproxy#3 0x7f5506763e1f  (/lib/x86_64-linux-gnu/libc.so.6+0x3fe1f) (BuildId: ea119b374e0f8f858c82ad03a9542414f9ea1c8c)
    envoyproxy#4 0x7f55067b7e5b in __pthread_kill_implementation nptl/pthread_kill.c:43:17
    envoyproxy#5 0x7f5506763d81 in raise signal/../sysdeps/posix/raise.c:26:13
    envoyproxy#6 0x7f550674c4ef in abort stdlib/abort.c:79:7
    envoyproxy#7 0x555ecc751905 in abort_message abort_message.cpp
    envoyproxy#8 0x555ecc751ae2 in demangling_terminate_handler() cxa_default_handlers.cpp
    envoyproxy#9 0x555ecc7519a2 in std::__terminate(void (*)()) cxa_handlers.cpp
    envoyproxy#10 0x555ecc750fd5 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) cxa_exception.cpp
    envoyproxy#11 0x555ecc750fbf in __cxa_throw (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x1310ffbf)
    envoyproxy#12 0x555ec97f5a1f in Envoy::ProtoExceptionUtil::throwProtoValidationException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, google::protobuf::Message const&) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x101b4a1f)
    envoyproxy#13 0x555ec3b87a1c in void Envoy::MessageUtil::validate<test::common::http::PathUtilityTestCase>(test::common::http::PathUtilityTestCase const&, Envoy::ProtobufMessage::ValidationVisitor&, bool) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa546a1c)
    envoyproxy#14 0x555ec3b277be in LLVMFuzzerTestOneInput (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa4e67be)
    envoyproxy#15 0x555ec39c9f60 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) cxa_noexception.cpp
    envoyproxy#16 0x555ec39c9785 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) cxa_noexception.cpp
    envoyproxy#17 0x555ec39cb712 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    envoyproxy#18 0x555ec39cba02 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    envoyproxy#19 0x555ec39b9eeb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) cxa_noexception.cpp
    envoyproxy#20 0x555ec39e5f12 in main (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa3a4f12)
    envoyproxy#21 0x7f550674dd67 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    envoyproxy#22 0x7f550674de24 in __libc_start_main csu/../csu/libc-start.c:360:3
    envoyproxy#23 0x555ec39ac720 in _start (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa36b720)

NOTE: libFuzzer has rudimentary signal handlers.
      Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
```

This PR adds a linking flag to allow the fuzzers to properly handle
exceptions.

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
Signed-off-by: Kyle O'Connor <oconnorkyle@google.com>
oconnorkyle pushed a commit to oconnorkyle/envoy that referenced this pull request Apr 23, 2025
When trying to build and run fuzzers that may throw an exception (e.g.,
`bazel build //test/common/http:path_utility_fuzz_test
--config=asan-fuzzer`) the following error occurs:
```
$ bazel-bin/test/common/http/path_utility_fuzz_test /tmp/corpus
INFO: found LLVMFuzzerCustomMutator (0x555ec3b27058). Disabling -len_control by default.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3031084950
INFO: Loaded 1 modules   (2436830 inline 8-bit counters): 2436830 [0x555ecf049c40, 0x555ecf29cb1e),
INFO: Loaded 1 PC tables (2436830 PCs): 2436830 [0x555ecf29cb20,0x555ed17cb900),
INFO:        5 files found in /tmp/corpus
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 5 min: 91b max: 332b total: 1208b rss: 357Mb
libc++abi: terminating due to uncaught exception of type Envoy::EnvoyException
==3072858== ERROR: libFuzzer: deadly signal
    #0 0x555ec3ae0911 in __sanitizer_print_stack_trace (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa49f911)
    envoyproxy#1 0x555ec39e56b8 in fuzzer::PrintStackTrace() cxa_noexception.cpp
    envoyproxy#2 0x555ec39c8a53 in fuzzer::Fuzzer::CrashCallback() cxa_noexception.cpp
    envoyproxy#3 0x7f5506763e1f  (/lib/x86_64-linux-gnu/libc.so.6+0x3fe1f) (BuildId: ea119b374e0f8f858c82ad03a9542414f9ea1c8c)
    envoyproxy#4 0x7f55067b7e5b in __pthread_kill_implementation nptl/pthread_kill.c:43:17
    envoyproxy#5 0x7f5506763d81 in raise signal/../sysdeps/posix/raise.c:26:13
    envoyproxy#6 0x7f550674c4ef in abort stdlib/abort.c:79:7
    envoyproxy#7 0x555ecc751905 in abort_message abort_message.cpp
    envoyproxy#8 0x555ecc751ae2 in demangling_terminate_handler() cxa_default_handlers.cpp
    envoyproxy#9 0x555ecc7519a2 in std::__terminate(void (*)()) cxa_handlers.cpp
    envoyproxy#10 0x555ecc750fd5 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) cxa_exception.cpp
    envoyproxy#11 0x555ecc750fbf in __cxa_throw (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x1310ffbf)
    envoyproxy#12 0x555ec97f5a1f in Envoy::ProtoExceptionUtil::throwProtoValidationException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, google::protobuf::Message const&) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x101b4a1f)
    envoyproxy#13 0x555ec3b87a1c in void Envoy::MessageUtil::validate<test::common::http::PathUtilityTestCase>(test::common::http::PathUtilityTestCase const&, Envoy::ProtobufMessage::ValidationVisitor&, bool) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa546a1c)
    envoyproxy#14 0x555ec3b277be in LLVMFuzzerTestOneInput (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa4e67be)
    envoyproxy#15 0x555ec39c9f60 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) cxa_noexception.cpp
    envoyproxy#16 0x555ec39c9785 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) cxa_noexception.cpp
    envoyproxy#17 0x555ec39cb712 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    envoyproxy#18 0x555ec39cba02 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    envoyproxy#19 0x555ec39b9eeb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) cxa_noexception.cpp
    envoyproxy#20 0x555ec39e5f12 in main (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa3a4f12)
    envoyproxy#21 0x7f550674dd67 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    envoyproxy#22 0x7f550674de24 in __libc_start_main csu/../csu/libc-start.c:360:3
    envoyproxy#23 0x555ec39ac720 in _start (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa36b720)

NOTE: libFuzzer has rudimentary signal handlers.
      Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
```

This PR adds a linking flag to allow the fuzzers to properly handle
exceptions.

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
Signed-off-by: Kyle O'Connor <oconnorkyle@google.com>
jtlisi pushed a commit to jtlisi/envoy that referenced this pull request Apr 24, 2025
When trying to build and run fuzzers that may throw an exception (e.g.,
`bazel build //test/common/http:path_utility_fuzz_test
--config=asan-fuzzer`) the following error occurs:
```
$ bazel-bin/test/common/http/path_utility_fuzz_test /tmp/corpus
INFO: found LLVMFuzzerCustomMutator (0x555ec3b27058). Disabling -len_control by default.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3031084950
INFO: Loaded 1 modules   (2436830 inline 8-bit counters): 2436830 [0x555ecf049c40, 0x555ecf29cb1e),
INFO: Loaded 1 PC tables (2436830 PCs): 2436830 [0x555ecf29cb20,0x555ed17cb900),
INFO:        5 files found in /tmp/corpus
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 5 min: 91b max: 332b total: 1208b rss: 357Mb
libc++abi: terminating due to uncaught exception of type Envoy::EnvoyException
==3072858== ERROR: libFuzzer: deadly signal
    #0 0x555ec3ae0911 in __sanitizer_print_stack_trace (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa49f911)
    envoyproxy#1 0x555ec39e56b8 in fuzzer::PrintStackTrace() cxa_noexception.cpp
    envoyproxy#2 0x555ec39c8a53 in fuzzer::Fuzzer::CrashCallback() cxa_noexception.cpp
    envoyproxy#3 0x7f5506763e1f  (/lib/x86_64-linux-gnu/libc.so.6+0x3fe1f) (BuildId: ea119b374e0f8f858c82ad03a9542414f9ea1c8c)
    envoyproxy#4 0x7f55067b7e5b in __pthread_kill_implementation nptl/pthread_kill.c:43:17
    envoyproxy#5 0x7f5506763d81 in raise signal/../sysdeps/posix/raise.c:26:13
    envoyproxy#6 0x7f550674c4ef in abort stdlib/abort.c:79:7
    envoyproxy#7 0x555ecc751905 in abort_message abort_message.cpp
    envoyproxy#8 0x555ecc751ae2 in demangling_terminate_handler() cxa_default_handlers.cpp
    envoyproxy#9 0x555ecc7519a2 in std::__terminate(void (*)()) cxa_handlers.cpp
    envoyproxy#10 0x555ecc750fd5 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) cxa_exception.cpp
    envoyproxy#11 0x555ecc750fbf in __cxa_throw (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x1310ffbf)
    envoyproxy#12 0x555ec97f5a1f in Envoy::ProtoExceptionUtil::throwProtoValidationException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, google::protobuf::Message const&) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0x101b4a1f)
    envoyproxy#13 0x555ec3b87a1c in void Envoy::MessageUtil::validate<test::common::http::PathUtilityTestCase>(test::common::http::PathUtilityTestCase const&, Envoy::ProtobufMessage::ValidationVisitor&, bool) (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa546a1c)
    envoyproxy#14 0x555ec3b277be in LLVMFuzzerTestOneInput (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa4e67be)
    envoyproxy#15 0x555ec39c9f60 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) cxa_noexception.cpp
    envoyproxy#16 0x555ec39c9785 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) cxa_noexception.cpp
    envoyproxy#17 0x555ec39cb712 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    envoyproxy#18 0x555ec39cba02 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) cxa_noexception.cpp
    envoyproxy#19 0x555ec39b9eeb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) cxa_noexception.cpp
    envoyproxy#20 0x555ec39e5f12 in main (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa3a4f12)
    envoyproxy#21 0x7f550674dd67 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    envoyproxy#22 0x7f550674de24 in __libc_start_main csu/../csu/libc-start.c:360:3
    envoyproxy#23 0x555ec39ac720 in _start (/usr/local/google/home/adip/.cache/bazel/_bazel_adip/8e88866af51670ff1222d99304421e7c/execroot/envoy/bazel-out/k8-fastbuild/bin/test/common/http/path_utility_fuzz_test+0xa36b720)

NOTE: libFuzzer has rudimentary signal handlers.
      Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
```

This PR adds a linking flag to allow the fuzzers to properly handle
exceptions.

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
Signed-off-by: Jacob Lisi <jtlisi@google.com>
rroblak added a commit to rroblak/envoy that referenced this pull request Jun 22, 2025
The Finagle-style refactoring introduced critical performance issues that
made Peak EWMA slower than Least Request. This commit fixes the mathematical
errors and restores Peak EWMA to envoyproxy#1 performance.

Key fixes:
- Fix alpha calculation: use proper time-weighted decay (1 - exp(-t/tau))
- Fix time gap logic: correct timestamp ordering and initialization
- Optimize decay time: 2 seconds default (equivalent to ~0.3 smoothing factor)
- Improve peak sensitivity: double learning rate for spikes vs hard reset
- Add proper bounds checking and fallback values

Performance improvements:
- Slow server avoidance: 1.1% (vs 1.3% Least Request, 8.7% Round Robin)
- Average response time: 18.5ms (vs 24.2ms Least Request, 152.3ms Round Robin)
- Peak EWMA now outperforms all other algorithms in both metrics

Technical changes:
- PeakEwmaCalculator: Fixed exponential decay formula and timing
- Default decay_time: Changed from 10s to 2s for responsiveness
- Test updates: Adjusted expectations for new algorithm behavior
- All 13 unit tests passing with corrected time-based behavior
rroblak added a commit to rroblak/envoy that referenced this pull request Jun 23, 2025
The Finagle-style refactoring introduced critical performance issues that
made Peak EWMA slower than Least Request. This commit fixes the mathematical
errors and restores Peak EWMA to envoyproxy#1 performance.

Key fixes:
- Fix alpha calculation: use proper time-weighted decay (1 - exp(-t/tau))
- Fix time gap logic: correct timestamp ordering and initialization
- Optimize decay time: 2 seconds default (equivalent to ~0.3 smoothing factor)
- Improve peak sensitivity: double learning rate for spikes vs hard reset
- Add proper bounds checking and fallback values

Performance improvements:
- Slow server avoidance: 1.1% (vs 1.3% Least Request, 8.7% Round Robin)
- Average response time: 18.5ms (vs 24.2ms Least Request, 152.3ms Round Robin)
- Peak EWMA now outperforms all other algorithms in both metrics

Technical changes:
- PeakEwmaCalculator: Fixed exponential decay formula and timing
- Default decay_time: Changed from 10s to 2s for responsiveness
- Test updates: Adjusted expectations for new algorithm behavior
- All 13 unit tests passing with corrected time-based behavior
rroblak added a commit to rroblak/envoy that referenced this pull request Jul 9, 2025
The Finagle-style refactoring introduced critical performance issues that
made Peak EWMA slower than Least Request. This commit fixes the mathematical
errors and restores Peak EWMA to envoyproxy#1 performance.

Key fixes:
- Fix alpha calculation: use proper time-weighted decay (1 - exp(-t/tau))
- Fix time gap logic: correct timestamp ordering and initialization
- Optimize decay time: 2 seconds default (equivalent to ~0.3 smoothing factor)
- Improve peak sensitivity: double learning rate for spikes vs hard reset
- Add proper bounds checking and fallback values

Performance improvements:
- Slow server avoidance: 1.1% (vs 1.3% Least Request, 8.7% Round Robin)
- Average response time: 18.5ms (vs 24.2ms Least Request, 152.3ms Round Robin)
- Peak EWMA now outperforms all other algorithms in both metrics

Technical changes:
- PeakEwmaCalculator: Fixed exponential decay formula and timing
- Default decay_time: Changed from 10s to 2s for responsiveness
- Test updates: Adjusted expectations for new algorithm behavior
- All 13 unit tests passing with corrected time-based behavior
ggmoy added a commit to ggmoy/envoy that referenced this pull request Aug 7, 2025
The previous test implementation was causing random TSAN (ThreadSanitizer)
failures in CI for the following test configurations:

  - IPv4_HttpDownstream_Http2UpstreamNghttp2Legacy_DownstreamFilter
  - IPv6_HttpDownstream_Http2UpstreamNghttp2Legacy_UpstreamFilter
  - IPv4_Http2Downstream_Http2UpstreamNghttp2Legacy_DownstreamFilter

Below is an extract of the stack trace from the GitHub Action workflow:

/bin/addr2line: DWARF error: invalid or unhandled FORM value: 0x25
==================
WARNING: ThreadSanitizer: data race (pid=35)
  Write of size 1 at 0x72100000bfb8 by main thread:
    #0 Envoy::Logger::DelegatingLogSink::setShouldEscape(bool) ??:? (lua_integration_test+0x3ffffd3)
    envoyproxy#1 Envoy::(anonymous namespace)::LuaIntegrationTest_MetadataFallbackToCanonicalName_Test::TestBody() lua_integration_test.cc:? (lua_integration_test+0x3f5745b)
    .
    .
    .

  Previous read of size 1 at 0x72100000bfb8 by thread T99 (mutexes: read M0):
    #0 Envoy::Logger::DelegatingLogSink::log(spdlog::details::log_msg const&)::$_0::operator()(Envoy::Logger::SinkDelegate&) const logger.cc:? (lua_integration_test+0xbb77fa2)
    envoyproxy#1 Envoy::Logger::DelegatingLogSink::log(spdlog::details::log_msg const&) ??:? (lua_integration_test+0xbb77e4c)
    envoyproxy#2 spdlog::logger::sink_it_(spdlog::details::log_msg const&) ??:? (lua_integration_test+0x3fa4772)
    .
    .
    .

  Location is heap block of size 64 at 0x72100000bf80 allocated by main thread:
    #0 malloc ??:? (lua_integration_test+0x3ec84cc)
    envoyproxy#1 operator new(unsigned long) ??:? (lua_integration_test+0xcb198b7)
    envoyproxy#2 Envoy::Logger::DelegatingLogSink::init() ??:? (lua_integration_test+0xbb7845e)
    envoyproxy#3 Envoy::Logger::Registry::getSink() ??:? (lua_integration_test+0x3fffec4)
    envoyproxy#4 Envoy::Logger::Context::activate() ??:? (lua_integration_test+0xbb78c10)
    envoyproxy#5 Envoy::Logger::Context::Context(spdlog::level::level_enum, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Envoy::Thread::BasicLockable&, bool, bool) ??:? (lua_integration_test+0xbb78b5c)
    envoyproxy#6 Envoy::TestRunner::runTests(int, char**) ??:? (lua_integration_test+0xa047b86)
    envoyproxy#7 main ??:? (lua_integration_test+0xa04549d)

  Mutex M0 (0x72100000bf98) created at:
    #0 __tsan_mutex_create ??:? (lua_integration_test+0x3f1b0cf)
    envoyproxy#1 absl::lts_20250512::Mutex::Mutex() ??:? (lua_integration_test+0x404374b)
    envoyproxy#2 Envoy::Logger::DelegatingLogSink::DelegatingLogSink() ??:? (lua_integration_test+0xbb7fa8e)
    envoyproxy#3 Envoy::Logger::DelegatingLogSink::init() ??:? (lua_integration_test+0xbb78470)
    envoyproxy#4 Envoy::Logger::Registry::getSink() ??:? (lua_integration_test+0x3fffec4)
    envoyproxy#5 Envoy::Logger::Context::activate() ??:? (lua_integration_test+0xbb78c10)
    envoyproxy#6 Envoy::Logger::Context::Context(spdlog::level::level_enum, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Envoy::Thread::BasicLockable&, bool, bool) ??:? (lua_integration_test+0xbb78b5c)
    envoyproxy#7 Envoy::TestRunner::runTests(int, char**) ??:? (lua_integration_test+0xa047b86)
    envoyproxy#8 main ??:? (lua_integration_test+0xa04549d)

  Thread T99 (tid=142, running) created by main thread at:
    #0 pthread_create ??:? (lua_integration_test+0x3ec9e2b)
    envoyproxy#1 Envoy::Thread::PosixThreadFactory::createPthread(Envoy::Thread::ThreadHandle*) ??:? (lua_integration_test+0xba8d202)
    envoyproxy#2 Envoy::Thread::PosixThreadFactory::createThread(std::__1::function<void ()>, std::__1::optional<Envoy::Thread::Options> const&, bool) ??:? (lua_integration_test+0xba8d406)
    envoyproxy#3 Envoy::Thread::PosixThreadFactory::createThread(std::__1::function<void ()>, std::__1::optional<Envoy::Thread::Options> const&) ??:? (lua_integration_test+0xba8d0cb)
    envoyproxy#4 Envoy::FakeUpstream::initializeServer() ??:? (lua_integration_test+0x55048cc)
    envoyproxy#5 Envoy::FakeUpstream::FakeUpstream(std::__1::unique_ptr<Envoy::Network::DownstreamTransportSocketFactory, std::__1::default_delete<Envoy::Network::DownstreamTransportSocketFactory> >&&, std::__1::unique_ptr<Envoy::Network::Socket, std::__1::default_delete<Envoy::Network::Socket> >&&, Envoy::FakeUpstreamConfig const&, bool) ??:? (lua_integration_test+0x5503f20)
    envoyproxy#6 Envoy::FakeUpstream::FakeUpstream(std::__1::unique_ptr<Envoy::Network::DownstreamTransportSocketFactory, std::__1::default_delete<Envoy::Network::DownstreamTransportSocketFactory> >&&, std::__1::shared_ptr<Envoy::Network::Address::Instance const> const&, Envoy::FakeUpstreamConfig const&) ??:? (lua_integration_test+0x5504491)
    .
    .
    .

SUMMARY: ThreadSanitizer: data race ??:? in Envoy::Logger::DelegatingLogSink::setShouldEscape(bool)

Signed-off-by: Gustavo Moyano <gustavo.g.moyano@gmail.com>
jue-yin pushed a commit to jue-yin/envoy that referenced this pull request Aug 21, 2025
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.

1 participant