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.
This commit is contained in:
Yikai Zhao 2023-10-11 19:43:28 +08:00 committed by Aliaksey Kandratsenka
parent c48d4f1407
commit dad9e8ceb9

View File

@ -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;