From 97b2408a186602f12e0a475bd5812de1bac9c275 Mon Sep 17 00:00:00 2001 From: Kateryna Nezdolii Date: Mon, 9 Sep 2024 21:46:02 +0200 Subject: [PATCH] Geoip fix asan failure (#36043) 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::allocator > >::__emplace_back_slow_path >(std::__1::function&&) /opt/llvm/bin/../include/c++/v1/vector:1558:49 #3 0x3348883 in std::__1::function& std::__1::vector, std::__1::allocator > >::emplace_back >(std::__1::function&&) /opt/llvm/bin/../include/c++/v1/vector:1580:9 #4 0x3348554 in Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)::operator()(std::__1::basic_string_view >, unsigned int, std::__1::function) const /proc/self/cwd/test/extensions/geoip_providers/maxmind/geoip_provider_test.cc:118:35 #5 0x334830e in decltype(static_cast, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)&>(fp)(static_cast >>(fp0), static_cast(fp0), static_cast>(fp0))) std::__1::__invoke, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)&, std::__1::basic_string_view >, unsigned int, std::__1::function >(Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)&, std::__1::basic_string_view >&&, unsigned int&&, std::__1::function&&) /opt/llvm/bin/../include/c++/v1/type_traits:3640:23 #6 0x33481c5 in absl::lts_20230802::Status std::__1::__invoke_void_return_wrapper::__call, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)&, std::__1::basic_string_view >, unsigned int, std::__1::function >(Envoy::Extensions::GeoipProviders::Maxmind::GeoipProviderTestBase::initializeProvider(std::__1::basic_string, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)&, std::__1::basic_string_view >&&, unsigned int&&, std::__1::function&&) /opt/llvm/bin/../include/c++/v1/__functional/invoke.h:30:16 #7 0x334819d in std::__1::__function::__alloc_func, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function), std::__1::allocator, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)>, absl::lts_20230802::Status (std::__1::basic_string_view >, unsigned int, std::__1::function)>::operator()(std::__1::basic_string_view >&&, unsigned int&&, std::__1::function&&) /opt/llvm/bin/../include/c++/v1/__functional/function.h:180:16 #8 0x3347993 in std::__1::__function::__func, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function), std::__1::allocator, std::__1::allocator > const&, std::__1::optional&)::'lambda'()::operator()() const::'lambda'(std::__1::basic_string_view >, unsigned int, std::__1::function)>, absl::lts_20230802::Status (std::__1::basic_string_view >, unsigned int, std::__1::function)>::operator()(std::__1::basic_string_view >&&, unsigned int&&, std::__1::function&&) /opt/llvm/bin/../include/c++/v1/__functional/function.h:354:12 #9 0x71758dd in std::__1::__function::__value_func >, unsigned int, std::__1::function)>::operator()(std::__1::basic_string_view >&&, unsigned int&&, std::__1::function&&) const /opt/llvm/bin/../include/c++/v1/__functional/function.h:507:16 #10 0x7175738 in std::__1::function >, unsigned int, std::__1::function)>::operator()(std::__1::basic_string_view >, unsigned int, std::__1::function) const /opt/llvm/bin/../include/c++/v1/__functional/function.h:1184:12 #11 0x71754e8 in decltype(std::forward >, unsigned int, std::__1::function)> const&>(fp)(std::get<0ul>(std::forward >, unsigned int, std::__1::function > >(fp0)), std::get<1ul>(std::forward >, unsigned int, std::__1::function > >(fp0)), std::get<2ul>(std::forward >, unsigned int, std::__1::function > >(fp0)))) testing::internal::ApplyImpl >, unsigned int, std::__1::function)> const&, std::__1::tuple >, unsigned int, std::__1::function >, 0ul, 1ul, 2ul>(std::__1::function >, unsigned int, std::__1::function)> const&, std::__1::tuple >, unsigned int, std::__1::function >&&, 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 >, unsigned int, std::__1::function)> const&>(fp), std::forward >, unsigned int, std::__1::function > >(fp0), (testing::internal::MakeIndexSequence >, unsigned int, std::__1::function > >::type>::value>)())) testing::internal::Apply >, unsigned int, std::__1::function)> const&, std::__1::tuple >, unsigned int, std::__1::function > >(std::__1::function >, unsigned int, std::__1::function)> const&, std::__1::tuple >, unsigned int, std::__1::function >&&) /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:429:10 #13 0x7174d47 in testing::Action >, unsigned int, std::__1::function)>::Perform(std::__1::tuple >, unsigned int, std::__1::function >) const /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-actions.h:497:12 #14 0x7175afd in testing::internal::ActionResultHolder* testing::internal::ActionResultHolder::PerformAction >, unsigned int, std::__1::function)>(testing::Action >, unsigned int, std::__1::function)> const&, testing::internal::Function >, unsigned int, std::__1::function)>::ArgumentTuple&&) /proc/self/cwd/external/com_google_googletest/googlemock/include/gmock/gmock-spec-builders.h:1402:24 #15 0x7173651 in testing::internal::FunctionMocker >, unsigned int, std::__1::function)>::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 >, unsigned int, std::__1::function)>::Invoke(std::__1::basic_string_view >, unsigned int, std::__1::function) /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 >, unsigned int, std::__1::function) /proc/self/cwd/./test/mocks/filesystem/mocks.h:78:3 #19 0x3405db9 in decltype(static_cast, std::__1::shared_ptr)::$_0&>(fp)()) std::__1::__invoke, std::__1::shared_ptr)::$_0&>(Envoy::Extensions::GeoipProviders::Maxmind::GeoipProvider::GeoipProvider(Envoy::Event::Dispatcher&, Envoy::Api::Api&, std::__1::shared_ptr, std::__1::shared_ptr)::$_0&) /proc/self/cwd/source/extensions/geoip_providers/maxmind/geoip_provider.cc:126:11 #20 0x3404a63 in std::__1::__function::__func, std::__1::shared_ptr)::$_0, std::__1::allocator, std::__1::shared_ptr)::$_0>, void ()>::operator()() /opt/llvm/bin/../include/c++/v1/__functional/invoke.h:61:9 #21 0x34f0239 in std::__1::__function::__value_func::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 --- test/extensions/geoip_providers/maxmind/geoip_provider_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/extensions/geoip_providers/maxmind/geoip_provider_test.cc b/test/extensions/geoip_providers/maxmind/geoip_provider_test.cc index b8d1cc93b647..6d3e8961d82a 100644 --- a/test/extensions/geoip_providers/maxmind/geoip_provider_test.cc +++ b/test/extensions/geoip_providers/maxmind/geoip_provider_test.cc @@ -94,6 +94,7 @@ class GeoipProviderTestBase { Registry::FactoryRegistry::getFactory( "envoy.geoip_providers.maxmind")); ASSERT(provider_factory_); + on_changed_cbs_.reserve(1); } ~GeoipProviderTestBase() {