Skip to content

TSAN error in SignalAction::sigHandler #2561

@brian-pane

Description

@brian-pane

Description:
The CircleCI TSAN run for one of my pull requests caught what appears to be an existing problem: a signal-unsafe call to new due to string processing within a signal handler.

Repro steps:
This happened at least once by running the integration tests with TSAN. I'm not sure whether it happens deterministically.

Call Stack:

WARNING: ThreadSanitizer: signal-unsafe call inside of a signal (pid=12258)
    #0 operator new(unsigned long) ??:? (ratelimit_integration_test+0x5c1e43)
    #1 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/basic_string.tcc:223 (ratelimit_integration_test+0xc7a0ec)
    #2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) ??:? (libstdc++.so.6+0x121c04)
    #3 Envoy::Logger::LockingStderrOrFileSink::log(spdlog::details::log_msg const&) /proc/self/cwd/external/envoy/source/common/common/logger.cc:46 (ratelimit_integration_test+0x19df8d2)
    #4 spdlog::logger::_sink_it(spdlog::details::log_msg&) /proc/self/cwd/external/com_github_gabime_spdlog/include/spdlog/details/logger_impl.h:321 (ratelimit_integration_test+0x5d63cc)
    #5 void spdlog::logger::log<char const*, void const*>(spdlog::level::level_enum, char const*, char const* const&, void const* const&) /proc/self/cwd/external/com_github_gabime_spdlog/include/spdlog/details/logger_impl.h:74 (ratelimit_integration_test+0x19d74f9)
    #6 void spdlog::logger::critical<char const*, void const*>(char const*, char const* const&, void const* const&) /proc/self/cwd/external/com_github_gabime_spdlog/include/spdlog/details/logger_impl.h:163 (ratelimit_integration_test+0x19d737d)
    #7 Envoy::BackwardsTrace::logFault(char const*, void const*) /proc/self/cwd/bazel-out/k8-dbg/bin/external/envoy/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:101 (ratelimit_integration_test+0x19d670f)
    #8 Envoy::SignalAction::sigHandler(int, siginfo_t*, void*) /proc/self/cwd/external/envoy/source/exe/signal_action.cc:30 (ratelimit_integration_test+0x19d528b)
    #9 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, bool, int, my_siginfo_t*, void*) crtstuff.c:? (ratelimit_integration_test+0x530c49)
    #10 non-virtual thunk to Envoy::(anonymous namespace)::RatelimitIntegrationTest_Ok_Test::TestBody() external/envoy/test/integration/ratelimit_integration_test.cc:? (ratelimit_integration_test+0x5c88af)
    #11 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2401 (ratelimit_integration_test+0x1f08206)
    #12 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2437 (ratelimit_integration_test+0x1eee961)
    #13 testing::Test::Run() /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2473 (ratelimit_integration_test+0x1ed723e)
    #14 testing::TestInfo::Run() /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2655 (ratelimit_integration_test+0x1ed82f1)
    #15 testing::TestCase::Run() /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2773 (ratelimit_integration_test+0x1ed8d37)
    #16 testing::internal::UnitTestImpl::RunAllTests() /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:4673 (ratelimit_integration_test+0x1ee455b)
    #17 bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2401 (ratelimit_integration_test+0x1f0d916)
    #18 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:2437 (ratelimit_integration_test+0x1ef24d7)
    #19 testing::UnitTest::Run() /proc/self/cwd/external/com_google_googletest/googletest/src/gtest.cc:4281 (ratelimit_integration_test+0x1ee3f6b)
    #20 RUN_ALL_TESTS() /proc/self/cwd/external/com_google_googletest/googletest/include/gtest/gtest.h:2237 (ratelimit_integration_test+0x15fbf27)
    #21 Envoy::TestRunner::RunTests(int, char**) /proc/self/cwd/external/envoy/test/test_runner.h:33 (ratelimit_integration_test+0x15fbde0)
    #22 main /proc/self/cwd/external/envoy/test/main.cc:35 (ratelimit_integration_test+0x15fae52)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions