Closed miteshdedhia7 closed 4 years ago
Hi @miteshdedhia7, thank you for informing us about the issue along with your analysis of the cause. We are looking into the issue, and will provide you an update soon.
Hello @miteshdedhia7, thanks for pointing out this issue. I have created a PR https://github.com/aws/amazon-freertos/pull/2181 to resolve this race-condition. You might want to look at the PR and if you would like, try it out as well to see if your issue is resolved. If the issue persists, tell us about it in comments below.
Hi @AniruddhaKanhere Thanks for the quick fix. The changes look good and should fix the problem.
Describe the bug There is a race condition in the TCP echo client demo that causes "Demo Runner" thread to finish before the "Echo" thread has finished.
DEMO_RUNNER_RunDemos
creates a thread that runs therunDemoTask
function.runDemoTask
then runs theDEMO_entryFUNCTION
which in the case of the TCP echo demo isvStartTCPEchoClientTasks_SingleTasks
which creates "Echo" thread that runs the demo and returns immediately. The "Demo Runner" thread and the "Echo" thread are at the same priority and therunDemoTask
does not wait for the "Echo" thread to finish before calling_cleanup
causing the network to be disabled before the "Echo" thread runs.Up till the 201910.00 branch the example runs fine in spite of the race condition because the
_cleanup
function did not disable the network but after https://github.com/aws/amazon-freertos/commit/4b7ca8864f8e8772d959f364c4915bfed31a3f71 the example stopped working because the network is disabled before the "Echo" thread starts communication.System information
git describe --tags
to find it) 202002.00Expected behavior The demo runs successfully with sending and receiving the message.
Screenshots or console output
Note that this screenshot was taken from the 201910.00 branch and hence runs the demo fine but notice that the "----DEMO FINISHED----" string printed in the
runDemoTask
appears even before the echo thread has started communication.To reproduce
Thank you!