Re: [RFC PATCH v4 1/2] arm64: Introduce stack trace reliability checks in the unwinder

Josh Poimboeuf
2021-05-21T20:08:14Z

On Fri, May 21, 2021 at 02:41:56PM -0500, Madhavan T. Venkataraman wrote:
> > Or is frame->reliable supposed to be checked after all? Looking at the
> > code again, I'm not sure.
> >
> > Either way it would be good to document the interface more clearly in a
> > comment above the function.
> >
>
> So, arch_stack_walk_reliable() would do this:
>
> start_backtrace(frame);
>
> while (...) {
> if (!frame->reliable)
> return error;
>
> consume_entry(...);
>
> ret = unwind_frame(...);
>
> if (ret)
> break;
> }
>
> if (ret == -ENOENT)
> return success;
> return error;
>
>
> Something like that.

I see. So basically there are six possible combinations of return
states:

1) No error frame->reliable
2) No error !frame->reliable
3) -ENOENT frame->reliable
5) -ENOENT !frame->reliable (doesn't happen in practice)
4) Other error frame->reliable (doesn't happen in practice)
6) Other error !frame->reliable

On x86 we have fewer combinations:

1) No error state->error
2) No error !state->error
3) Error state->error
4) Error !state->error (doesn't happen in practice)

I think the x86 interface seems more robust, because it's more narrow
and has fewer edge cases. Also it doesn't have to distinguish between
error enums, which can get hairy if a downstream callee happens to
return -ENOENT for a different reason.

--
Josh