-
Notifications
You must be signed in to change notification settings - Fork 1.5k
arch/sim: save errno in sim context switch to avoid coroutine make errno mess between host api calls. #16795
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
Conversation
b38680a to
7c32224
Compare
|
@yamt could you review whether this patchset fix your concern? |
|
Thank you @jasonbu :-) Do we have some sort of nuke test application for this case where corner cases can be generated and verified? It may be good to see how things are handled on various Sim:OS (i.e. Linux, BSD, macOS, etc)? Is the code in PR description enough / sufficient to cover all scenarios or just a starting point? Can we put that as starting point of |
There is some dependency if reproduce with this code,
so in my environment, sim/citest cannot reproduce, but in internal project can reproduce with less than 10000 times loop. if you have time to ensure it reproduced and add to sim-testing will appreciate |
7c32224 to
d351fa2
Compare
hi, @cederom , The 1 million times test, will not able to reproduce the problem. In the real-complex scene. True issue will be, if we don't use host_uninterruptible_errno, will cause errno randomly covered by other host-API. And if we depends errno to do host behavior(should be regular desisng). errno occupation will cause a mess. CC @yamt |
|
Thank you @jasonbu :-)
|
cederom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jasonbu for the fix! Let's just make sure CI build errors are fixed before merge :-)
cederom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Linker error fix :-)
…rno" This reverts commit ac5b38c. Keep host_errno_convert as a common interface in sim_internal.h Keep the up_irq_save & up_irq_restore as common interface Signed-off-by: buxiasen <buxiasen@xiaomi.com>
8fac768
d351fa2 to
8fac768
Compare
Ths for review, and help find where CI report error, the host_uninterruptible_errno usage increased during these days. fixed, and please check. |
We will remove the API in next commit, so remove the errno manual save API and save errno more commonly. After whole pull request, should no longer need to care about errno. Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Avoid the errno changed after interrupt in sim and make return value mistake when according to errno. Move host_errno_convert from macro to sim_errno.c. Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Avoid the errno changed after interrupt in sim and make return value mistake when according to errno. Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Or will cause the fork break as call will auto push 1 item. Signed-off-by: buxiasen <buxiasen@xiaomi.com>
8fac768 to
f8d10c8
Compare
Summary
As discussion in #16742, manually up_irq_save is not a good idea, we should save errno in "interrupt" to ensure the errno use as usual will more easy to mantain.
This patch add errno in sim context, and save it before call coroutine setjump, restore before longjump.
When there is lot of sim feature provide by host, the errno may change by coroutine/switch context/...
The code to reproduce issue:
paste it into apps/examples/hello/hello_main.c
Impact
Now we don't have to take care the errno changed when "interrupt" happened. the context switch will matain the errno correctly.
Code to reproduce will no longer report break.
Testing
CI test, ubuntu 24.04 sim/nsh, local complex sim project.
After revert ac5b38c and add a host_errno_get & host_errno_set.
These demo will able to re-produce it in sim/nsh.
rmdir fail: Unknown error 21 (errno: 21) child errno thread end break after 3579966 times, ret: 0and succ after whole pr.