-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[BUG] pthread_getspecific possibly called before pthread_key_create #1236
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
Comments
Double checked, Breakpoints at both locations.
Run
|
Hi @denravonska |
I was able to reproduce it in Docker using this Mint image and the patch seems to have fixed it. |
Thanks for confirming . I will raise a PR shortly to address the issue. |
The PR #1238 which addresses the issue has been verified and merged. |
Describe the bug
!1223 introduced a way to mark threads as FreeRTOS threads. This works fine on 3 of our 4 development stations (3 local stations and one CI) but once one of our developer updated the code base he started experiencing crashes in the tests, see additional context.
The lines in question,
port.c:169
, looks harmless:The only reason that dereference can fail is if the returned pointer is not-NULL and points to invalid memory. The only way this can happen is if passing a key that has not been obtained from
pthread_key_create
If we add a call to
prvInitThreadKey()
inprvIsFreeRTOSThread()
before the key is retrieved the crashes stopped, which leads me to believe that the malloc path entersprvIsFreeRTOSThread()
before any call to the key creation. I haven't verified this as I have no way of reproducing it.See the pthread_getspecific and pthread_key_create man pages. In particular the
thread_key_create
one which usespthread_once
rather than manual tracking to construct the key only onceTarget
Host
Works on:
Crashes on:
To Reproduce
Not 100% sure but my hypothesis is to create a task (not static) with heap4 from main.
Additional context
The text was updated successfully, but these errors were encountered: