]> granicus.if.org Git - p11-kit/commitdiff
Implement valgrind's hellgrind checks for threading problems
authorStef Walter <stefw@gnome.org>
Wed, 15 May 2013 09:51:22 +0000 (11:51 +0200)
committerStef Walter <stefw@gnome.org>
Wed, 15 May 2013 09:51:22 +0000 (11:51 +0200)
And cleanup our locks/locking model. There's no need to use
recursive locks, especially since we can't use them on all
platforms. In addition adjust taking of locks during initialization
so that there's no chance of deadlocking here.

automaint.sh
build/Makefile.decl
build/Makefile.tests
common/compat.c
p11-kit/modules.c

index 975556dc2fea95fc61df7f612db2fe2cee53db89..96cb60c5796559464ab66ef40cbdf614bba1f300 100755 (executable)
@@ -41,7 +41,7 @@ done
                echo '  done'
        done
 
-       for target in distcheck memcheck leakcheck install upload-coverage \
+       for target in distcheck memcheck leakcheck hellcheck install upload-coverage \
                coverage upload-doc upload-release transifex; do
                echo "$target:"
                echo '  $(MAKE) -C ./local' $target
index c90c22b81b9ff2cad8f48ec4ffe7a0d25f0ac038..8dca4e784195f7c5cae7a3ff24a7f8cc6ecb9362 100644 (file)
@@ -9,3 +9,8 @@ leakcheck:
        @for dir in $(SUBDIRS); do \
                test "$$dir" = "." || $(MAKE) -C $$dir leakcheck; \
        done
+
+hellcheck:
+       @for dir in $(SUBDIRS); do \
+               test "$$dir" = "." || $(MAKE) -C $$dir hellcheck; \
+       done
index 3faa7f3d848c0c016f58561577862e9b89433745..0c5b85c81903b32e61233f54130f0ac51c95aa75 100644 (file)
@@ -12,8 +12,13 @@ MEMCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=80 --quiet --trace-child
 
 LEAKCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=81 --quiet --leak-check=yes
 
+HELLCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=82 --quiet --tool=helgrind
+
 memcheck: all
        make $(AM_MAKEFLAGS) TESTS_ENVIRONMENT="$(MEMCHECK_ENV)" check-TESTS
 
 leakcheck: all
        make $(AM_MAKEFLAGS) TESTS_ENVIRONMENT="$(LEAKCHECK_ENV)" check-TESTS
+
+hellcheck: all
+       make $(AM_MAKEFLAGS) TESTS_ENVIRONMENT="$(HELLCHECK_ENV)" check-TESTS
index 4d8d73c16e94572ff6d8e8f1055ea08da726673e..b8ed2ad3eab73b1804f7509220da122950fa2768 100644 (file)
@@ -161,7 +161,7 @@ p11_mutex_init (p11_mutex_t *mutex)
        int ret;
 
        pthread_mutexattr_init (&attr);
-       pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+       pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_DEFAULT);
        ret = pthread_mutex_init (mutex, &attr);
        assert (ret == 0);
        pthread_mutexattr_destroy (&attr);
index 19ba895b3d71f1f0ef1733cc628b81b9c4802591..e62a43cf21bf71cc8b21211a76100477dc482390 100644 (file)
@@ -531,8 +531,8 @@ initialize_module_unlocked_reentrant (Module *mod)
        mod->initialize_thread = self;
 
        /* Change over to the module specific mutex */
-       p11_mutex_lock (&mod->initialize_mutex);
        p11_unlock ();
+       p11_mutex_lock (&mod->initialize_mutex);
 
        if (!mod->initialize_called) {
                assert (mod->funcs);