Skip to content

Commit

Permalink
update to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Nov 21, 2023
1 parent 3a14d8e commit 1ba69b7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 42 deletions.
3 changes: 1 addition & 2 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ ExternalProject_Add(gperftools
URL ${OSS_URL_PREFIX}/gperftools-2.13.tar.gz
https://github.com/gperftools/gperftools/releases/download/gperftools-2.13/gperftools-2.13.tar.gz
URL_MD5 4e218a40a354748c50d054c285caaae8
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_gpertools-Fix-result-overflow-in-generic_fp-stacktrace.patch
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_gpertools-generic_fp-stacktrace-check-frame-size-threshold-for.patch
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_gperftools-generic_fp.patch
CONFIGURE_COMMAND ./configure --prefix=${TP_OUTPUT} --enable-static=no --enable-frame-pointers=yes
BUILD_IN_SOURCE 1
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
From 8a8d6a378232b2f813ef31a8729820dad5d758e8 Mon Sep 17 00:00:00 2001
From f74212f40055d78d54cadf473907c7f0fbe1b6d1 Mon Sep 17 00:00:00 2001
From: Yikai Zhao <[email protected]>
Date: Mon, 25 Sep 2023 19:04:23 +0800
Subject: [PATCH] generic_fp stacktrace: check frame size threshold for initial
frame

Fix result overflow in generic_fp stacktrace

In the 'with ucontext' case, the `skip_count` would be reset to 0, and
`max_depth` should not be modified. Otherwise the result array would overflow.
---
src/stacktrace_generic_fp-inl.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
src/stacktrace_generic_fp-inl.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/stacktrace_generic_fp-inl.h b/src/stacktrace_generic_fp-inl.h
index aa32bc5..1412a68 100644
index aa32bc5..91fedef 100644
--- a/src/stacktrace_generic_fp-inl.h
+++ b/src/stacktrace_generic_fp-inl.h
@@ -123,8 +123,6 @@ int capture(void **result, int max_depth, int skip_count,
int *sizes) {
int i = 0;

- max_depth += skip_count;
-
if (initial_pc != nullptr) {
// This is 'with ucontext' case. We take first pc from ucontext
// and then skip_count is ignored as we assume that caller only
@@ -137,6 +135,8 @@ int capture(void **result, int max_depth, int skip_count,
i++;
}

+ max_depth += skip_count;
+
constexpr uintptr_t kTooSmallAddr = 16 << 10;
constexpr uintptr_t kFrameSizeThreshold = 128 << 10;

@@ -156,6 +156,7 @@ int capture(void **result, int max_depth, int skip_count,
constexpr uintptr_t kAlignment = 16;
#endif
Expand Down

This file was deleted.

0 comments on commit 1ba69b7

Please sign in to comment.