summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-07-15 14:02:36 +0200
committerIvan Maidanski <ivmai@mail.ru>2013-07-15 14:02:36 +0200
commit991f1a8a5ced31df77ea81a1f53116a8b5f34eea (patch)
tree4b16f23bff3728a981705a4893d0708de81c79b9
parent84c483185f85bc574eeea2ae316d25062a02d296 (diff)
Add double-lock assertion to GC_acquire_mark_lock
* pthread_support.c (GC_acquire_mark_lock): Add assertion that GC_mark_lock_holder is not set to the current thread on the function entry (i.e., assertion against double lock). * win32_threads.c (GC_acquire_mark_lock): Likewise.
-rw-r--r--pthread_support.c1
-rw-r--r--win32_threads.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 975c081..334be50 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -1963,6 +1963,7 @@ static pthread_cond_t builder_cv = PTHREAD_COND_INITIALIZER;
GC_INNER void GC_acquire_mark_lock(void)
{
+ GC_ASSERT(GC_mark_lock_holder != NUMERIC_THREAD_ID(pthread_self()));
GC_generic_lock(&mark_mutex);
# ifdef GC_ASSERTIONS
GC_mark_lock_holder = NUMERIC_THREAD_ID(pthread_self());
diff --git a/win32_threads.c b/win32_threads.c
index 32e42ce..2462c2a 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -1786,6 +1786,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
GC_INNER void GC_acquire_mark_lock(void)
{
+ GC_ASSERT(GC_mark_lock_holder != NUMERIC_THREAD_ID(pthread_self()));
if (pthread_mutex_lock(&mark_mutex) != 0) {
ABORT("pthread_mutex_lock failed");
}
@@ -1971,6 +1972,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
GC_INNER void GC_acquire_mark_lock(void)
{
+ GC_ASSERT(GC_mark_lock_holder != (unsigned long)GetCurrentThreadId());
# ifdef DONT_USE_SIGNALANDWAIT
if (InterlockedExchange(&GC_mark_mutex_state, 1 /* locked */) != 0)
# else