Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With the most recent changes, we were exiting threads via the fault-in-the-switcher path. The new code put the initial csp (full bounds, address 16 bytes from the top) on the first trusted-stack frame. When we tried to pop this, we were getting a bounds fault because we tried to restore two registers from the 16-byte offset for error handlers / local state, and then a third one from off the top. This then triggered a bounds fault in the switcher and we bounced to the thread-exit path. Prior to the most recent change, the top trusted-stack frame had a 0 csp, so we'd get a tag violation and hit the same path a couple of instructions earlier. This was due to the fact that our bounds check was checking if the *current* trusted stack frame was the top one, not checking the previous one. The fix for that was simply to move the subtraction earlier. This then caused a worse error because the (unused, due to other bugs) path into the thread exit code was not restoring the trusted stack pointer into csp where the exception path expected it. This is now fixed. Reported by @rmn30, who noticed that we were taking a surprising number of exceptions in the hello world example. We now take precisely one: the tag error when we do the `cjr $cra` to return from a thread entry-point function that doesn't have a caller.
- Loading branch information