diff options
| author | Frédéric Desbiens <[email protected]> | 2026-10-02 10:42:44 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-10-02 10:42:44 -0400 |
| commit | 93387b0a60382a29579bbad5045c68328e3751df (patch) | |
| tree | 42be790d602cb76f55090e5a7c418df7ea2b3428 /utility/rtos_compatibility_layers/posix/px_pth_init.c | |
| parent | 44d7c95c582d415c4ad84527180b29c93c3bf664 (diff) | |
| parent | 28281cd5647d4671236ca08d19bd18ed15b2265a (diff) | |
Merge pull request #783 from eclipse-threadx/devv6.5.2.202603_rel
Merged changes ahead of the v6.5.2.202603 release
Diffstat (limited to 'utility/rtos_compatibility_layers/posix/px_pth_init.c')
| -rw-r--r-- | utility/rtos_compatibility_layers/posix/px_pth_init.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/utility/rtos_compatibility_layers/posix/px_pth_init.c b/utility/rtos_compatibility_layers/posix/px_pth_init.c index 5d2f36ad..ff0a01a9 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_init.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_init.c @@ -538,12 +538,30 @@ POSIX_TCB *p_tcb; if (!thread_ptr) { /* Not called from a thread - error! */ - posix_internal_error(222); + posix_internal_error(222); + + /* posix_internal_error() does not return today, but do not depend on + that: posix_thread2tcb() hands back NULL for this input and the read + below would dereference it. A pthread ID is the address of the TCB, + so zero is never a valid one. */ + return((pthread_t) 0); } /* Get the TCB for this pthread */ p_tcb = posix_thread2tcb(thread_ptr); + + /* A running ThreadX thread that was not created through pthread_create() + has no TCB in the pool, and posix_thread2tcb() returns NULL for it. It + has no pthread ID either, so report zero rather than reading through the + null pointer. Zero can never collide with a real ID, because + px_pth_create.c uses the address of the TCB as the ID. */ + if (!p_tcb) + { + + return((pthread_t) 0); + } + thread_ID = p_tcb->pthreadID; /* All done. */ |
