-
Notifications
You must be signed in to change notification settings - Fork 5
IllegalInstruction exception when using embassy
in release mode
#3
Comments
The issue is caused by multiple problems - also in esp-hal! However I found the problem here: riscv-atomic-emulation-trap/src/lib.rs Line 10 in 4131904
The slot for X0 is used for the PC in the trap-frame but that breaks emulation of instruction that use |
The issue for the problem in esp-hal is here: esp-rs/esp-hal#206 |
@TheButlah The two mentioned PRs should (together) fix the issue. You can try it locally by patching the dependencies. Your example worked for me this way but would be great if you could give it a try |
Will try soon! Y'all are awesome, thank you so much for putting up with my barrage of matrix messages ❤ |
Btw I saw somewhere that this would cause problems with esp-wifi, is that true? I was going to try out esp-wifi next |
I have tested by patching |
I opened an issue in embassy for this but I believe it actually belongs here.
Here is a minimally reproducible example.
Now, my understanding of all of this is very limited so take what I say with a grain of salt, but it appears as though either the atomics are not actually properly emulated, or that there is some sort of low level safety issue happening.
I have been able to confirm that if I don't use embassy and just try using a combination of
core::sync::atomic
andcritical_section::Mutex
and do stuff, I wasn't able to reproduce the issue. So using embassy appears to be the best way to reproduce the bug.The bug only occurs when compiling for the
-imac
instruction set, and only when embassy is built withopt-level = 1
or higher. This code works as expected inopt-level = 0
.In case its helpful, here is some additional context from the esp-rs matrix server, where @Dirbaio did some digging into alternative workarounds that might make the trap handler obsolete. Please note that regardless, there is still a bug in the atomic trap handler
The text was updated successfully, but these errors were encountered: