Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes the stack walking implementation of
unwind2
more resilient and useful outside of panics. The big fix here is that apparently leaf functions do not spill their return address to the stack instead keeping it in register and EH_FRAME has no explicit instructions on how to recover that. At least according to LLVMs libunwindhttps://github.com/llvm/llvm-project/blob/6de5d1e46d1812de2bbbbe8d8d2c811e4d16acbe/libunwind/src/DwarfInstructions.hpp#L295-L296
Kind of annoyed that this was so obscure and difficult to find :/
In the way we previously used stack walking this was fine since
save_context
always explicitly pushed the return address onto the stack:k23/libs/unwind2/src/arch/riscv64.rs
Lines 216 to 219 in 4c7edf0
In essence when called through
begin_unwind
there never was a leaf function that would show this behavior.But now with this fixed we can finally construct stack traces from inside the kernels teap handler too! (In the trap handler we don't control where the return address lives, so need to deal with it potentially not being on stack at all).