Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Change unwinder to mark registers as "unknown" when they don't appear in an unwind table row #284

Open
jonas-schievink opened this issue Nov 24, 2021 · 0 comments
Labels
difficulty: medium Somewhat difficult to solve status: needs PR Issue just needs a Pull Request implementing the changes topic: unwinding type: bug Something isn't working

Comments

@jonas-schievink
Copy link
Contributor

Before unwinding is started, all registers have the value in the physical CPU registers. During unwinding, we use the rules in the matching unwind table row to restore all registers to their value in the previous frame:

for (reg, rule) in uwt_row.registers() {
unwrap_or_return_output!(registers.update(reg, rule));
}
let lr = unwrap_or_return_output!(registers.get(registers::LR));

However, there's an implicit rule that we currently ignore: if a register does not appear in that list, its value is lost and can not be recovered. Currently, we just leave it at its old value, which can cause the unwinder to veer off into memory it shouldn't touch.

We should change the unwinder to track "unrecoverable" registers, and make it bail out when a register it needs (mostly LR or PC, SP is handled differently) is unrecoverable.

Note that this has the chance of affecting real-world programs that just happen to unwind correctly despite unrecoverable registers, but I think those should be rare (rustc tries to keep registers needed for unwinding intact).

@jonas-schievink jonas-schievink added type: bug Something isn't working difficulty: medium Somewhat difficult to solve status: needs PR Issue just needs a Pull Request implementing the changes topic: unwinding labels Nov 24, 2021
@Urhengulas Urhengulas added this to Incoming in Issue Triage via automation Dec 13, 2021
@Lotterleben Lotterleben self-assigned this Dec 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
difficulty: medium Somewhat difficult to solve status: needs PR Issue just needs a Pull Request implementing the changes topic: unwinding type: bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

3 participants