This repository was archived by the owner on Jan 24, 2022. It is now read-only.
This repository was archived by the owner on Jan 24, 2022. It is now read-only.
Add force-setting of stack pointer in startup code #254
Closed
Description
During experimenting with new unsafe code I realized that the stack pointer can easily be corrupted, and this can propagate and stick after a system reset while having a debugger connected.
This causes preinit
to automatically hardfault if using the stack and the zeroing/init of RAM under no optimization also directly hardfaults.
I propose we add the code to always hard-load the stack pointer from the vector table.
It will cost a few bytes, but I argue that it is a price worth to pay to have stable debug/implementation runs.
Currently it is trivial to get into a very hard to debug state.