FreeRTOS / FreeRTOS-Kernel

FreeRTOS kernel files only, submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
https://www.FreeRTOS.org
MIT License
2.51k stars 1.05k forks source link

Fix race in prvProcessSimulatedInterrupts #1055

Closed aggarg closed 1 month ago

aggarg commented 1 month ago

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:

Related Issue

https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/1054.

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

sonarcloud[bot] commented 1 month ago

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