From 755f29b35e1b3d65d36541c8250e0509ecf4f632 Mon Sep 17 00:00:00 2001 From: Wiktor Garbacz Date: Tue, 29 Nov 2022 03:23:59 -0800 Subject: [PATCH] Correct unwinding stop condition On successful completion, `unw_step()` returns a positive value if the updated cursor refers to a valid stack frame, or `0` if the previous stack frame was the last frame in the chain. On error, the negative value of one of the error-codes below is returned. PiperOrigin-RevId: 491588164 Change-Id: Ie361023ef69eed6c895856832a8208f2791f644d --- sandboxed_api/sandbox2/unwind/unwind.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sandboxed_api/sandbox2/unwind/unwind.cc b/sandboxed_api/sandbox2/unwind/unwind.cc index e62a458..6efc4e6 100644 --- a/sandboxed_api/sandbox2/unwind/unwind.cc +++ b/sandboxed_api/sandbox2/unwind/unwind.cc @@ -86,12 +86,7 @@ absl::StatusOr> RunLibUnwind(pid_t pid, int max_frames) { break; } ips.push_back(ip); - rc = unw_step(&cursor); - // Non-error condition: UNW_ESUCCESS (0). - if (rc < 0) { - // If anything but UNW_ESTOPUNWIND (-5), there has been an error. - // However since we can't do anything about it and it appears that - // this happens every time we don't log this. + if (unw_step(&cursor) <= 0) { break; } }