From d56aa41a1af6acbc761cf73e2ea312697777bd3c Mon Sep 17 00:00:00 2001 From: Alain Spineux Date: Fri, 3 Sep 2021 17:07:18 +0200 Subject: [PATCH] Extend lockmgr to allow the use of destructor in pthread_key_create() - if a destructor use a lock then the lockmgr cannot find the thread (that is being destructed) anymore and fail to update the list for this thread. - instead we check that we have a thread alive before to update it. - TODO maybe we should also do the same check for other use of "self" in lockmgr.c --- bacula/src/lib/lockmgr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bacula/src/lib/lockmgr.c b/bacula/src/lib/lockmgr.c index 4323e5226..f9f17485d 100644 --- a/bacula/src/lib/lockmgr.c +++ b/bacula/src/lib/lockmgr.c @@ -1022,9 +1022,9 @@ int bthread_mutex_unlock_p(bthread_mutex_t *m, const char *file, int line) int bthread_mutex_lock_p(pthread_mutex_t *m, const char *file, int line) { lmgr_thread_t *self = lmgr_get_thread_info(); - self->pre_P(m, 0, file, line); + if (self) self->pre_P(m, 0, file, line); lmgr_p(m); - self->post_P(); + if (self) self->post_P(); return 0; } @@ -1035,7 +1035,7 @@ int bthread_mutex_lock_p(pthread_mutex_t *m, const char *file, int line) int bthread_mutex_unlock_p(pthread_mutex_t *m, const char *file, int line) { lmgr_thread_t *self = lmgr_get_thread_info(); - self->do_V(m, file, line); + if (self) self->do_V(m, file, line); lmgr_v(m); return 0; } -- 2.47.3