-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISC-V/ESP32-C3] IllegalInstruction Exception on yield_now().await
but only in --release
#995
Comments
I found that the The question is, why is it using that instruction address? I genuinely have no idea. Its either a bug in rustc itself or a bug in embassy, and I'm at a loss for how to figure it out. If there is anything I can do to help give more info that would make it possible to solve this, let me know. This is super out of my comfort zone. |
I have been able to narrow down this error. If I remove all atomics from my code (and my dependencies), and change my compilation target to I think this is because riscv-atomic-emulation-trap, seems to not be handling the atomic - that is the most likely culprit. I'm not sure if its the fault of embassy or the atomic trap. |
I was unable to reproduce this bug with a minimal program of me using just critical sections, mutexes, and atomics, so I still believe it has something to do with embassy. I have made the example even more minimal by eliminating Simplified code is here I am getting this error log (note that I've added
Note that an |
Some progress is being made finally. I compiled with
|
Here is the latest information I collected, compiled with Observed behavior: See the log - in summary, code crashes due to an IllegalInstruction exception. Please note that this code works if compiling with link to code Log:
Objdump (snippet is the region around the
As you can see, atomic emulation is a transitive dependency so it should be working
|
embassy
in release mode
esp-rs/riscv-atomic-emulation-trap#3
closing, bug is in esp-rs/riscv-atomic-emulation-trap#3 |
Minimally reproducible example: link
Embassy Versions tested:
cb9f0ef5b800ce4a22cde1805e0eb88425f1e07b
(what I had when I initially hit this)f075e624440af121da7a27a145e2acee0730c542
(tried again with latestmain
)This code operates as expected when doing a regular debug build. However, in
--release
mode, it triggers anIllegalInstruction
exception. According to my (preliminary and uninformed) research, this may be an indication of a soundness issue in embassy where we are executing an invalid opcode.If I set a breakpoint on a
yield_now().await
in probe-rs, clicking play appears to resume the code at the same spot, without hitting any of the debug statements after the yield.If I remove all the breakpoints and hit play, I immediately hit my ExceptionHandler with an
IllegalInstruction
exception.sometimes the loops manage to execute a couple times, before the exception occurs. I've seen it happen as fast as on the very first yield, and as slow as 18 iterations.
Here is the log:
The text was updated successfully, but these errors were encountered: