eina: replace memsets in thread debugging lock create/free with manual zeroing
authorMike Blumenkrantz <zmike@samsung.com>
Tue, 19 Jun 2018 17:30:20 +0000 (13:30 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Tue, 19 Jun 2018 21:44:57 +0000 (06:44 +0900)
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
src/lib/eina/eina_lock.c

index 604a5ac..9dd96eb 100644 (file)
@@ -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;
 }
index 00dc4fd..9c560df 100644 (file)
@@ -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