From b25fdb4a2e02d4f5429da1827fc3485f283d3d04 Mon Sep 17 00:00:00 2001 From: Meredith Heller Date: Mon, 11 Aug 2025 14:34:31 -0700 Subject: [PATCH 1/4] ref(gnu-integration): make path optional --- sentry_sdk/integrations/gnu_backtrace.py | 2 +- tests/integrations/test_gnu_backtrace.py | 30 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/gnu_backtrace.py b/sentry_sdk/integrations/gnu_backtrace.py index 21d8ea9b38..d6a1a26084 100644 --- a/sentry_sdk/integrations/gnu_backtrace.py +++ b/sentry_sdk/integrations/gnu_backtrace.py @@ -15,7 +15,7 @@ FUNCTION_RE = r"[^@]+?)\s+@\s+0x[0-9a-fA-F]+" FRAME_RE = r""" -^(?P\d+)\.\s+(?P{FUNCTION_RE}\s+in\s+(?P.+)$ +^(?P\d+)\.\s+(?P{FUNCTION_RE}(?:\s+in\s+(?P.+))? """.format( FUNCTION_RE=FUNCTION_RE, ) diff --git a/tests/integrations/test_gnu_backtrace.py b/tests/integrations/test_gnu_backtrace.py index 63930f850d..a8e2dda67e 100644 --- a/tests/integrations/test_gnu_backtrace.py +++ b/tests/integrations/test_gnu_backtrace.py @@ -31,8 +31,36 @@ 24. ? @ 0x00000000000d162c in /usr/lib/aarch64-linux-gnu/libc-2.31.so """ +LINES_NO_PATH = r""" +0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000bfc38a4 +1. DB::Exception::Exception(int, FormatStringHelperImpl::type, std::type_identity::type>, String&&, String&&) @ 0x00000000075d242c +2. DB::ActionsMatcher::visit(DB::ASTIdentifier const&, std::shared_ptr const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1c648 +3. DB::ActionsMatcher::visit(DB::ASTFunction const&, std::shared_ptr const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1f58c +4. DB::ActionsMatcher::visit(DB::ASTFunction const&, std::shared_ptr const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1f58c +5. DB::ActionsMatcher::visit(std::shared_ptr const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1c394 +6. DB::InDepthNodeVisitor const>::doVisit(std::shared_ptr const&) @ 0x0000000010b154a0 +7. DB::ExpressionAnalyzer::getRootActions(std::shared_ptr const&, bool, std::shared_ptr&, bool) @ 0x0000000010af83b4 +8. DB::SelectQueryExpressionAnalyzer::appendSelect(DB::ExpressionActionsChain&, bool) @ 0x0000000010aff168 +9. DB::ExpressionAnalysisResult::ExpressionAnalysisResult(DB::SelectQueryExpressionAnalyzer&, std::shared_ptr const&, bool, bool, bool, std::shared_ptr const&, std::shared_ptr const&, DB::Block const&) @ 0x0000000010b05b74 +10. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x00000000111559fc +11. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::shared_ptr const&, std::shared_ptr const&, std::optional, std::shared_ptr const&, DB::SelectQueryOptions const&, std::vector> const&, std::shared_ptr const&, std::shared_ptr)::$_0::operator()(bool) const @ 0x0000000011148254 +12. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::shared_ptr const&, std::shared_ptr const&, std::optional, std::shared_ptr const&, DB::SelectQueryOptions const&, std::vector> const&, std::shared_ptr const&, std::shared_ptr) @ 0x00000000111413e8 +13. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::shared_ptr const&, std::shared_ptr, DB::SelectQueryOptions const&, std::vector> const&) @ 0x00000000111d3708 +14. DB::InterpreterFactory::get(std::shared_ptr&, std::shared_ptr, DB::SelectQueryOptions const&) @ 0x0000000011100b64 +15. DB::executeQueryImpl(char const*, char const*, std::shared_ptr, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x00000000114c3f3c +16. DB::executeQuery(String const&, std::shared_ptr, bool, DB::QueryProcessingStage::Enum) @ 0x00000000114c0ec8 +17. DB::TCPHandler::runImpl() @ 0x00000000121bb5d8 +18. DB::TCPHandler::run() @ 0x00000000121cb728 +19. Poco::Net::TCPServerConnection::start() @ 0x00000000146d9404 +20. Poco::Net::TCPServerDispatcher::run() @ 0x00000000146da900 +21. Poco::PooledThread::run() @ 0x000000001484da7c +22. Poco::ThreadImpl::runnableEntry(void*) @ 0x000000001484bc24 +23. start_thread @ 0x0000000000007624 +24. ? @ 0x00000000000d162c +""" + -@pytest.mark.parametrize("input", LINES.strip().splitlines()) +@pytest.mark.parametrize("input", LINES.strip().splitlines() + LINES_NO_PATH.strip().splitlines()) def test_basic(sentry_init, capture_events, input): sentry_init(integrations=[GnuBacktraceIntegration()]) events = capture_events() From eee5ed56059fa011710a57c1a7787cf732d92e9e Mon Sep 17 00:00:00 2001 From: Meredith Heller Date: Mon, 11 Aug 2025 15:28:16 -0700 Subject: [PATCH 2/4] add $ --- sentry_sdk/integrations/gnu_backtrace.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/gnu_backtrace.py b/sentry_sdk/integrations/gnu_backtrace.py index d6a1a26084..7440c4e85b 100644 --- a/sentry_sdk/integrations/gnu_backtrace.py +++ b/sentry_sdk/integrations/gnu_backtrace.py @@ -11,11 +11,12 @@ from typing import Any from sentry_sdk._types import Event - +# function is everything between index at @ +# and then we match on the @ plus the hex val FUNCTION_RE = r"[^@]+?)\s+@\s+0x[0-9a-fA-F]+" FRAME_RE = r""" -^(?P\d+)\.\s+(?P{FUNCTION_RE}(?:\s+in\s+(?P.+))? +^(?P\d+)\.\s+(?P{FUNCTION_RE}(?:\s+in\s+(?P.+))?$ """.format( FUNCTION_RE=FUNCTION_RE, ) From 4e2c1c096f6bdd6ae42b11fa660228c73a4bb4f8 Mon Sep 17 00:00:00 2001 From: Meredith Heller Date: Mon, 11 Aug 2025 15:31:51 -0700 Subject: [PATCH 3/4] split regex --- sentry_sdk/integrations/gnu_backtrace.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/gnu_backtrace.py b/sentry_sdk/integrations/gnu_backtrace.py index 7440c4e85b..8241e27f13 100644 --- a/sentry_sdk/integrations/gnu_backtrace.py +++ b/sentry_sdk/integrations/gnu_backtrace.py @@ -13,12 +13,14 @@ # function is everything between index at @ # and then we match on the @ plus the hex val -FUNCTION_RE = r"[^@]+?)\s+@\s+0x[0-9a-fA-F]+" +FUNCTION_RE = r"[^@]+?" +HEX_ADDRESS = r"\s+@\s+0x[0-9a-fA-F]+" FRAME_RE = r""" -^(?P\d+)\.\s+(?P{FUNCTION_RE}(?:\s+in\s+(?P.+))?$ +^(?P\d+)\.\s+(?P{FUNCTION_RE}){HEX_ADDRESS}(?:\s+in\s+(?P.+))?$ """.format( FUNCTION_RE=FUNCTION_RE, + HEX_ADDRESS=HEX_ADDRESS, ) FRAME_RE = re.compile(FRAME_RE, re.MULTILINE | re.VERBOSE) From ffffd4bb22bf57beff73acb2e66e39d60aee1dc5 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 12 Aug 2025 13:13:24 +0200 Subject: [PATCH 4/4] black --- tests/integrations/test_gnu_backtrace.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integrations/test_gnu_backtrace.py b/tests/integrations/test_gnu_backtrace.py index a8e2dda67e..be7346a2c3 100644 --- a/tests/integrations/test_gnu_backtrace.py +++ b/tests/integrations/test_gnu_backtrace.py @@ -60,7 +60,9 @@ """ -@pytest.mark.parametrize("input", LINES.strip().splitlines() + LINES_NO_PATH.strip().splitlines()) +@pytest.mark.parametrize( + "input", LINES.strip().splitlines() + LINES_NO_PATH.strip().splitlines() +) def test_basic(sentry_init, capture_events, input): sentry_init(integrations=[GnuBacktraceIntegration()]) events = capture_events()