diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2021-04-21 12:00:44 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2021-05-05 11:10:39 +0300 |
commit | 1b143992013dcc63e89cffa9ec07d426b2c0f5fd (patch) | |
tree | 65eecc89e07963f9c51546707191bb96f16d2d23 | |
parent | 057a52f1ead1c0b2bc2aefc603c69ac844891774 (diff) |
linux-gen: thread: set _odp_this_thread to NULL in term_local
Set _odp_this_thread to NULL in _odp_thread_term_local(), in order to
not leave behind a dangling reference.
In development of thread specific log function (in a future commit), a
segmentation fault occurred in _odp_fdserver_term_global(). This was
caused by _odp_this_thread being dereferenced (to check for thread
specific log function) after _odp_thread_term_global(), which frees
the shm that _odp_this_thread points to.
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
-rw-r--r-- | platform/linux-generic/odp_thread.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index 170bf82b7..6c50b60d0 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -231,6 +231,8 @@ int _odp_thread_term_local(void) if (type == ODP_THREAD_CONTROL && group_control) _odp_sched_fn->thr_rem(ODP_SCHED_GROUP_CONTROL, id); + _odp_this_thread = NULL; + odp_spinlock_lock(&thread_globals->lock); num = free_id(id); odp_spinlock_unlock(&thread_globals->lock); |