From 2d02dccf22cbd9030910b3551eb5bcf53ba203be Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 19 Jun 2018 13:30:20 -0400 Subject: [PATCH] eina: replace memsets in thread debugging lock create/free with manual zeroing Summary: memset overwrites the thread value, triggering errors when running tools like helgrind attempting an operation on an invalid thread will cause errors naturally, so zeroing the rest of the struct and ignoring the thread member is fine Reviewers: ManMower, devilhorns Reviewed By: ManMower Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6297 --- src/lib/eina/eina_inline_lock_posix.x | 6 ++++++ src/lib/eina/eina_lock.c | 8 -------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/eina/eina_inline_lock_posix.x b/src/lib/eina/eina_inline_lock_posix.x index 604a5ac..9dd96eb 100644 --- a/src/lib/eina/eina_inline_lock_posix.x +++ b/src/lib/eina/eina_inline_lock_posix.x @@ -162,6 +162,9 @@ eina_lock_new(Eina_Lock *mutex) Eina_Bool ret = _eina_lock_new(mutex, EINA_FALSE); #ifdef EINA_HAVE_DEBUG_THREADS mutex->recursive = EINA_FALSE; + mutex->lock_thread_id = 0; + mutex->lock_bt_num = 0; + mutex->locked = 0; #endif return ret; } @@ -172,6 +175,9 @@ eina_lock_recursive_new(Eina_Lock *mutex) Eina_Bool ret = _eina_lock_new(mutex, EINA_TRUE); #ifdef EINA_HAVE_DEBUG_THREADS mutex->recursive = EINA_TRUE; + mutex->lock_thread_id = 0; + mutex->lock_bt_num = 0; + mutex->locked = 0; #endif return ret; } diff --git a/src/lib/eina/eina_lock.c b/src/lib/eina/eina_lock.c index 00dc4fd..9c560df 100644 --- a/src/lib/eina/eina_lock.c +++ b/src/lib/eina/eina_lock.c @@ -95,7 +95,6 @@ _eina_lock_new(Eina_Lock *mutex, Eina_Bool recursive) } #ifdef EINA_HAVE_DEBUG_THREADS else if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) goto fail_release; - memset(mutex, 0, sizeof(Eina_Lock)); #endif if (pthread_mutex_init(&(mutex->mutex), &attr) != 0) goto fail_release; ok = EINA_TRUE; @@ -111,9 +110,6 @@ _eina_lock_free(Eina_Lock *mutex) ok = pthread_mutex_destroy(&(mutex->mutex)); if (ok != 0) EINA_LOCK_ABORT_DEBUG(ok, mutex_destroy, mutex); -#ifdef EINA_HAVE_DEBUG_THREADS - memset(mutex, 0, sizeof(Eina_Lock)); -#endif } EAPI Eina_Bool @@ -124,7 +120,6 @@ _eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex) #ifdef EINA_HAVE_DEBUG_THREADS assert(mutex != NULL); - memset(cond, 0, sizeof (Eina_Condition)); #endif cond->lock = mutex; @@ -167,9 +162,6 @@ EAPI void _eina_condition_free(Eina_Condition *cond) { pthread_cond_destroy(&(cond->condition)); -#ifdef EINA_HAVE_DEBUG_THREADS - memset(cond, 0, sizeof (Eina_Condition)); -#endif } EAPI Eina_Bool -- 2.7.4