mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-10-09 23:53:04 -04:00
prvInitThreadKey() ignored pthread_key_create()'s return value, and prvMarkAsFreeRTOSThread() ignored pthread_setspecific()'s return value. If pthread_setspecific() fails, the one-byte thread marker allocated just before it is neither stored in TLS (so prvThreadKeyDestructor() never runs for it, leaking the allocation) nor freed locally -- and the thread is left unmarked, so prvIsFreeRTOSThread() silently misclassifies it as not a FreeRTOS thread. The correctness impact (thread identity) is larger than the one-byte leak itself. Fix: check both return values. On pthread_setspecific() failure, free the marker to avoid the leak, then call prvFatalError() -- the same handling this port already uses for other unexpected pthread call failures (pthread_create(), sigaction()). This function returns void, so there is no way to propagate a failure to the caller; continuing past a failed pthread_setspecific() would leave the thread silently misclassified rather than failing loudly. Same treatment for pthread_key_create(), since a failure there means every later pthread_setspecific()/pthread_getspecific() call on xThreadKey is operating on an invalid key. Fixes #1447 Signed-off-by: Saikumar Mandaji <mandajisaikumar@gmail.com> |
||
|---|---|---|
| .. | ||
| ARMClang | ||
| ARMv8M | ||
| BCC/16BitDOS | ||
| CCRH/F1Kx | ||
| CCS | ||
| CodeWarrior | ||
| Common | ||
| GCC | ||
| IAR | ||
| Keil | ||
| MemMang | ||
| MikroC/ARM_CM4F | ||
| MPLAB | ||
| MSVC-MingW | ||
| oWatcom/16BitDOS | ||
| Paradigm/Tern_EE | ||
| Renesas | ||
| Rowley | ||
| RVDS | ||
| SDCC/Cygnal | ||
| Softune | ||
| Tasking/ARM_CM4F | ||
| template | ||
| ThirdParty | ||
| WizC/PIC18 | ||
| CMakeLists.txt | ||
| readme.txt | ||
Each real time kernel port consists of three files that contain the core kernel components and are common to every port, and one or more files that are specific to a particular microcontroller and/or compiler. + The FreeRTOS/Source/Portable/MemMang directory contains the five sample memory allocators as described on the https://www.FreeRTOS.org WEB site. + The other directories each contain files specific to a particular microcontroller or compiler, where the directory name denotes the compiler specific files the directory contains. For example, if you are interested in the [compiler] port for the [architecture] microcontroller, then the port specific files are contained in FreeRTOS/Source/Portable/[compiler]/[architecture] directory. If this is the only port you are interested in then all the other directories can be ignored.