-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
POSIX Simulator: Clear SIGRESUME (SIGUSR1) when exiting xPortStartScheduler #1224
Conversation
I'll undo this change in my local fork of FreeRTOS and see if I still have issues. It might be that this was solved by #1223 |
I still have this issue, though I don't fully understand why |
85c76ce
to
94263d2
Compare
As you already mentioned, this seems like a hack. Do I need a mac to repro it or is it reproducible on Linux? |
@aggarg I haven't gotten to trying on Linux yet but I can give it a shot. I'm reproducing in macOS with LLDB. I wonder if LLDB could be triggering this strange behavior somehow. |
Can you try running without the debugger? |
I tried to reproduce the issue on Ubuntu 20.04 , but running it with or without the debugger, the issue is not reproduced. Code used
Results after running without debugger
Results after running with debugger
I also tried your change in
Result on Ubuntu:
|
I can't repro/observe this issue without the debugger. I'm not sure if that means the issue isn't happening, or if it means the issue is happening but not observable. Would you expect the program to crash when it gets the SIGUSR1 signal when restoring the signals in
@kar-rahul-aws so you were able to repro this on macOS? |
No, I would not expect that to crash. |
Hello @johnboiles,
Once set, this configuration remains in effect until explicitly changed. |
Hi @bhoomrs, thanks for the suggestion! However, It looks like it does not resolve the issue, but instead just ignores the breakpoint when the signal fires. The program still terminates execution at the
While if running outside of LLDB it completes the program (the final
Is this consistent with what you're seeing? I'm definitely open to a |
This is the output I get while running the demo with lldb in the terminal:
I acknowledge that this approach doesn’t actually fix the underlying error—it simply ignores it, much like in GDB. |
@bhoomrs I'm not sure where to put the
If I set
I think that's an acceptable workaround if it can be documented somewhere. Though I would suggest that keeping this 4-line with a comment is maybe a good place to document it! ;) I added a |
|
That sounds reasonable. We can create a README here and document it.
This check seems like addressing a race rather than fixing the root cause and therefore, I do not think we should add this. The above mentioned |
I can accept that now that we have a workaround. Thanks for considering it. |
@johnboiles Thank you for bringing this to our attention! |
While using the macOS default LLDB debugger, a call to vTaskEndScheduler results in an unhandled SIGUSR1 (aka SIGRESUME) when restoring the scheduler thread's signals with pthread_sigmask. This crashes the program. Added instructions in portable/ThirdParty/GCC/Posix/port.c to suppress SIGUSR1 to prevent LLDB debugger interference when exiting xPortStartScheduler Thanks to: @johnboiles for pointing it out in #1224
Clear
SIGRESUME
(SIGUSR1
) when exiting xPortStartSchedulerDescription
When attempting to stop the scheduler via
vTaskEndScheduler
, an unhandledSIGUSR1
(akaSIGRESUME
) happens when restoring the scheduler thread's signals withpthread_sigmask
. This crashes the program.I'm not sure why this is happening since
sigwait
is supposed to consume the pending signals. It's possible there's something platform-specific about this. I'm testing on macOS. If the behavior is different on other platforms however, it probably can't hurt to double check. What's particularly interesting is if I modify this code like this:I then get this:
Which means
sigwait
the first time is returning an invalid signal0
but also a return code suggesting that it succeeded! Strange!Test Steps
Testing with this example (full code: freertos-pr1224.zip ):
Without this fix, I see in
lldb
:Checklist: