Skip to content
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

Fix race in prvProcessSimulatedInterrupts #1055

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

aggarg
Copy link
Member

@aggarg aggarg commented May 14, 2024

Description

Earlier the code was suspending the current thread after calling vTaskSwitchContext. This left a gap where the current thread could access incorrect pxCurrentTCB after it was changed by vTaskSwitchContext.

This PR addresses the problem by suspending the current thread before calling vTaskSwitchContext.

Test Steps

Build and run the following demo - https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS/Demo/WIN32-MSVC

Checklist:

  • I have tested my changes. No regression in existing tests.
  • [NA] I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

#1054.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Earlier the code was suspending the current thread after calling
vTaskSwitchContext. This left a gap where the current thread could
access incorrect pxCurrentTCB after it was changed by
vTaskSwitchContext.

This commit addresses the problem by suspending the current thread
before calling vTaskSwitchContext.

It was reported here - FreeRTOS#1054.

Signed-off-by: Gaurav Aggarwal <[email protected]>
@aggarg aggarg requested a review from a team as a code owner May 14, 2024 07:45
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@aggarg aggarg merged commit 2e0c623 into FreeRTOS:main May 14, 2024
16 checks passed
@aggarg aggarg deleted the winsim branch May 14, 2024 10:45
schilkp pushed a commit to schilkp/FreeRTOS-Kernel that referenced this pull request May 17, 2024
Earlier the code was suspending the current thread after calling
vTaskSwitchContext. This left a gap where the current thread could
access incorrect pxCurrentTCB after it was changed by
vTaskSwitchContext.

This commit addresses the problem by suspending the current thread
before calling vTaskSwitchContext.

It was reported here - FreeRTOS#1054.

Signed-off-by: Gaurav Aggarwal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants