|
From: Paul F. <pa...@so...> - 2021-10-07 19:34:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=85bbe2853e813bbd83aa17bc17c2b73d82f6bc3e commit 85bbe2853e813bbd83aa17bc17c2b73d82f6bc3e Author: Paul Floyd <pj...@wa...> Date: Thu Oct 7 21:33:45 2021 +0200 FreeBSD support, patch 5 drd and helgrind tests Diff: --- .gitignore | 7 + configure.ac | 14 + drd/tests/Makefile.am | 23 +- drd/tests/annotate_smart_pointer.cpp | 3 + drd/tests/bar_bad.stderr.exp-freebsd | 45 ++++ drd/tests/bar_bad_xml.stderr.exp-freebsd | 286 +++++++++++++++++++++ drd/tests/circular_buffer.c | 22 +- drd/tests/concurrent_close.cpp | 3 + drd/tests/concurrent_close.vgtest | 2 +- .../{filter_error_count => filter_error_count.in} | 4 +- ...ilter_error_summary => filter_error_summary.in} | 4 +- drd/tests/{filter_stderr => filter_stderr.in} | 8 +- drd/tests/filter_stderr_and_thread_no_and_offset | 4 - .../filter_stderr_and_thread_no_and_offset.in | 6 + .../{filter_thread_no => filter_thread_no.in} | 4 +- ...l_and_thread_no => filter_xml_and_thread_no.in} | 4 +- drd/tests/pth_create_chain.c | 5 + drd/tests/pth_detached3.c | 8 + drd/tests/pth_detached3.stderr.exp-freebsd | 14 + drd/tests/pth_detached3.stderr.exp2 | 4 +- drd/tests/pth_uninitialized_cond.vgtest | 1 + drd/tests/recursive_mutex.stderr.exp-freebsd | 18 ++ drd/tests/std_list.cpp | 27 +- drd/tests/std_string.cpp | 3 + drd/tests/std_thread2.supp | 26 ++ drd/tests/tc09_bad_unlock.stderr.exp-freebsd | 49 ++++ drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang | 49 ++++ drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 | 46 ++-- drd/tests/tc22_exit_w_lock.vgtest | 1 + drd/tests/tc23_bogus_condwait.stderr.exp-freebsd | 40 +++ drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 | 44 ++-- drd/tests/thread_name.vgtest | 2 +- drd/tests/thread_name_freebsd.c | 63 +++++ drd/tests/thread_name_freebsd.stderr.exp | 93 +++++++ drd/tests/thread_name_freebsd.vgtest | 3 + drd/tests/thread_name_xml.vgtest | 2 +- helgrind/tests/Makefile.am | 13 +- helgrind/tests/bar_bad.c | 3 + helgrind/tests/bar_bad.stderr.exp-destroy-hang | 18 +- helgrind/tests/bar_bad.stderr.exp-freebsd | 58 +++++ helgrind/tests/filter_freebsd.awk | 148 +++++++++++ helgrind/tests/{filter_stderr => filter_stderr.in} | 20 +- helgrind/tests/filter_stderr_freebsd | 60 +++++ .../tests/locked_vs_unlocked2.stderr.exp-freebsd | 44 ++++ .../tests/locked_vs_unlocked3.stderr.exp-freebsd | 34 +++ .../tests/pth_cond_destroy_busy.stderr.exp-freebsd | 24 ++ .../tests/tc06_two_races_xml.stderr.exp-freebsd | 251 ++++++++++++++++++ helgrind/tests/tc07_hbl1.c | 9 +- helgrind/tests/tc08_hbl2.c | 9 +- helgrind/tests/tc09_bad_unlock.c | 3 + helgrind/tests/tc09_bad_unlock.stderr.exp | 72 +++--- helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd | 150 +++++++++++ helgrind/tests/tc09_bad_unlock.stderr.exp-solaris | 72 +++--- helgrind/tests/tc11_XCHG.c | 9 +- helgrind/tests/tc12_rwl_trivial.c | 2 +- helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd | 31 +++ helgrind/tests/tc17_sembar.c | 5 +- helgrind/tests/tc18_semabuse.stderr.exp-freebsd | 40 +++ helgrind/tests/tc20_verifywrap.c | 2 +- helgrind/tests/tc20_verifywrap.vgtest | 2 +- helgrind/tests/tc22_exit_w_lock.vgtest | 1 + helgrind/tests/tc23_bogus_condwait.c | 9 +- helgrind/tests/tc23_bogus_condwait.stderr.exp | 14 +- .../tests/tc23_bogus_condwait.stderr.exp-freebsd | 100 +++++++ helgrind/tests/tc24_nonzero_sem.c | 5 +- tests/check_makefile_consistency | 2 +- tests/os_test.c | 4 + 67 files changed, 1975 insertions(+), 176 deletions(-) diff --git a/.gitignore b/.gitignore index 86962b4780..ac16d3638a 100644 --- a/.gitignore +++ b/.gitignore @@ -354,6 +354,12 @@ /drd/tests/*.stderr.out /drd/tests/*.stdout.diff* /drd/tests/*.stdout.out +/drd/tests/filter_error_count +/drd/tests/filter_error_summary +/drd/tests/filter_stderr +/drd/tests/filter_stderr_and_thread_no_and_offset +/drd/tests/filter_thread_no +/drd/tests/filter_xml_and_thread_no /drd/tests/.deps /drd/tests/annotate_barrier /drd/tests/annotate_hb_err @@ -629,6 +635,7 @@ /helgrind/tests/*.stderr.out /helgrind/tests/*.stdout.diff* /helgrind/tests/*.stdout.out +/helgrind/tests/filter_stderr /helgrind/tests/.deps /helgrind/tests/annotate_hbefore /helgrind/tests/annotate_rwlock diff --git a/configure.ac b/configure.ac index c05994516f..7e6773606d 100755 --- a/configure.ac +++ b/configure.ac @@ -5215,6 +5215,20 @@ AC_CONFIG_FILES([tests/filter_stderr_basic], [chmod +x tests/filter_stderr_basic]) AC_CONFIG_FILES([tests/filter_discards], [chmod +x tests/filter_discards]) +AC_CONFIG_FILES([drd/tests/filter_stderr], + [chmod +x drd/tests/filter_stderr]) +AC_CONFIG_FILES([drd/tests/filter_error_count], + [chmod +x drd/tests/filter_error_count]) +AC_CONFIG_FILES([drd/tests/filter_error_summary], + [chmod +x drd/tests/filter_error_summary]) +AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset], + [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset]) +AC_CONFIG_FILES([drd/tests/filter_thread_no], + [chmod +x drd/tests/filter_thread_no]) +AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no], + [chmod +x drd/tests/filter_xml_and_thread_no]) +AC_CONFIG_FILES([helgrind/tests/filter_stderr], + [chmod +x helgrind/tests/filter_stderr]) AC_OUTPUT cat<<EOF diff --git a/drd/tests/Makefile.am b/drd/tests/Makefile.am old mode 100644 new mode 100755 index 07650ef88a..4cb2f7f84a --- a/drd/tests/Makefile.am +++ b/drd/tests/Makefile.am @@ -87,10 +87,12 @@ EXTRA_DIST = \ bar_bad.stderr.exp \ bar_bad.stderr.exp-nohang \ bar_bad.stderr.exp-solaris \ + bar_bad.stderr.exp-freebsd \ bar_bad.vgtest \ bar_bad_xml.stderr.exp \ bar_bad_xml.stderr.exp-nohang \ bar_bad_xml.stderr.exp-solaris \ + bar_bad_xml.stderr.exp-freebsd \ bar_bad_xml.vgtest \ bar_trivial.stderr.exp \ bar_trivial.stdout.exp \ @@ -213,6 +215,7 @@ EXTRA_DIST = \ pth_detached2.vgtest \ pth_detached3.stderr.exp1 \ pth_detached3.stderr.exp2 \ + pth_detached3.stderr.exp-freebsd \ pth_detached3.vgtest \ pth_detached_sem.stderr.exp \ pth_detached_sem.stdout.exp \ @@ -235,6 +238,7 @@ EXTRA_DIST = \ recursive_mutex.stderr.exp-linux \ recursive_mutex.stderr.exp-darwin \ recursive_mutex.stderr.exp-solaris \ + recursive_mutex.stderr.exp-freebsd \ recursive_mutex.vgtest \ rwlock_race.stderr.exp \ rwlock_race.stderr.exp2 \ @@ -313,6 +317,8 @@ EXTRA_DIST = \ tc09_bad_unlock.stderr.exp-glibc2.8 \ tc09_bad_unlock.stderr.exp-s390 \ tc09_bad_unlock.stderr.exp-solaris \ + tc09_bad_unlock.stderr.exp-freebsd \ + tc09_bad_unlock.stderr.exp-freebsd-clang \ tc09_bad_unlock.vgtest \ tc10_rec_lock.stderr.exp \ tc10_rec_lock.vgtest \ @@ -345,6 +351,7 @@ EXTRA_DIST = \ tc23_bogus_condwait.stderr.exp-linux-ppc \ tc23_bogus_condwait.stderr.exp-darwin-x86 \ tc23_bogus_condwait.stderr.exp-darwin-amd64 \ + tc23_bogus_condwait.stderr.exp-freebsd \ tc23_bogus_condwait.vgtest \ tc24_nonzero_sem.stderr.exp \ tc24_nonzero_sem.vgtest \ @@ -352,6 +359,8 @@ EXTRA_DIST = \ thread_name.vgtest \ thread_name_xml.stderr.exp \ thread_name_xml.vgtest \ + thread_name_freebsd.stderr.exp \ + thread_name_freebsd.vgtest \ threaded-fork.stderr.exp \ threaded-fork.vgtest \ threaded-fork-vcs.stderr.exp \ @@ -410,7 +419,11 @@ check_PROGRAMS = \ threaded-fork \ trylock \ unit_bitmap \ - unit_vc + unit_vc \ + std_atomic \ + std_list \ + std_mutex \ + std_string if HAVE_BOOST_1_35 check_PROGRAMS += boost_thread @@ -440,10 +453,6 @@ endif if CXX_CAN_INCLUDE_THREAD_HEADER if HAVE_SHARED_POINTER_ANNOTATION check_PROGRAMS += \ - std_atomic \ - std_list \ - std_mutex \ - std_string \ std_thread \ std_thread2 endif @@ -480,6 +489,10 @@ if !VGCONF_OS_IS_DARWIN check_PROGRAMS += sem_wait endif +if VGCONF_OS_IS_FREEBSD +check_PROGRAMS += thread_name_freebsd +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ -Wno-inline -Wno-unused-parameter AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ @FLAG_FALIGNED_NEW@ \ diff --git a/drd/tests/annotate_smart_pointer.cpp b/drd/tests/annotate_smart_pointer.cpp index ccefc47350..a6c1a9d524 100644 --- a/drd/tests/annotate_smart_pointer.cpp +++ b/drd/tests/annotate_smart_pointer.cpp @@ -37,6 +37,7 @@ #include <pthread.h> // pthread_mutex_t #endif #include "unified_annotations.h" +#include "config.h" static bool s_enable_annotations; @@ -142,7 +143,9 @@ public: { pthread_attr_t attr; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 4096); +#endif pthread_create(&m_tid, &attr, pf, arg); pthread_attr_destroy(&attr); } diff --git a/drd/tests/bar_bad.stderr.exp-freebsd b/drd/tests/bar_bad.stderr.exp-freebsd new file mode 100644 index 0000000000..00276e462d --- /dev/null +++ b/drd/tests/bar_bad.stderr.exp-freebsd @@ -0,0 +1,45 @@ + + +initialise a barrier with zero count +pthread_barrier_init: 'count' argument is zero: barrier 0x........ + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +initialise a barrier twice +Barrier reinitialization: barrier 0x........ + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +initialise a barrier which has threads waiting on it +Barrier reinitialization: barrier 0x........ + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +destroy a barrier that has waiting threads +Destruction of a barrier with active waiters: barrier 0x........ + at 0x........: pthread_barrier_destroy (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +destroy a barrier that was never initialised +Destruction of barrier that is being waited upon: barrier 0x........ + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/bar_bad_xml.stderr.exp-freebsd b/drd/tests/bar_bad_xml.stderr.exp-freebsd new file mode 100644 index 0000000000..24ac7fe952 --- /dev/null +++ b/drd/tests/bar_bad_xml.stderr.exp-freebsd @@ -0,0 +1,286 @@ +<?xml version="1.0"?> + +<valgrindoutput> + +<protocolversion>4</protocolversion> +<protocoltool>drd</protocoltool> + +<preamble> + <line>...</line> + <line>...</line> + <line>...</line> + <line>...</line> +</preamble> + +<pid>...</pid> +<ppid>...</ppid> +<tool>drd</tool> + +<args> + <vargv>...</vargv> + <argv> + <exe>./../../helgrind/tests/bar_bad</exe> + </argv> +</args> + +<status> + <state>RUNNING</state> + <time>...</time> +</status> + + +initialise a barrier with zero count +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>pthread_barrier_init: 'count' argument is zero: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> +</error> + + +initialise a barrier twice +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Barrier reinitialization: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +initialise a barrier which has threads waiting on it +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Barrier reinitialization: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +destroy a barrier that has waiting threads +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Destruction of a barrier with active waiters: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_destroy</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +destroy a barrier that was never initialised +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Destruction of barrier that is being waited upon: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>free</fn> + <dir>...</dir> + <file>vg_replace_malloc.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +<status> + <state>FINISHED</state> + <time>...</time> +</status> + +<errorcounts> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> +</errorcounts> + +<suppcounts>...</suppcounts> + +</valgrindoutput> + diff --git a/drd/tests/circular_buffer.c b/drd/tests/circular_buffer.c index 0b750467b7..d84ac01273 100644 --- a/drd/tests/circular_buffer.c +++ b/drd/tests/circular_buffer.c @@ -48,6 +48,12 @@ typedef struct { data_t buffer[BUFFER_MAX]; } buffer_t; +typedef struct id_and_wait_s +{ + int id; + int wait_time; +} id_and_wait_t; + static int quiet = 0; static int use_locking = 1; @@ -158,7 +164,8 @@ static buffer_t b; static void *producer(void* arg) { - int* id = arg; + id_and_wait_t* ctx = arg; + int* id = &ctx->id; buffer_send(&b, id); return NULL; @@ -168,14 +175,16 @@ static void *producer(void* arg) static void *consumer(void* arg) { - int* id = arg; + id_and_wait_t* ctx = arg; + int id = ctx->id; + int wait_time = ctx->wait_time; int d; - usleep(rand() % MAXSLEEP); + usleep(wait_time); buffer_recv(&b, &d); if (! quiet) { - printf("%i: %i\n", *id, d); + printf("%i: %i\n", id, d); fflush(stdout); } return NULL; @@ -187,7 +196,7 @@ int main(int argc, char** argv) { pthread_t producers[THREADS]; pthread_t consumers[THREADS]; - int thread_arg[THREADS]; + id_and_wait_t thread_arg[THREADS]; int i; int optchar; @@ -210,7 +219,8 @@ int main(int argc, char** argv) for (i = 0; i < THREADS; ++i) { - thread_arg[i] = i; + thread_arg[i].id = i; + thread_arg[i].wait_time = rand() % MAXSLEEP; pthread_create(producers + i, NULL, producer, &thread_arg[i]); } diff --git a/drd/tests/concurrent_close.cpp b/drd/tests/concurrent_close.cpp index 9f7e6d622f..e098dd37a5 100644 --- a/drd/tests/concurrent_close.cpp +++ b/drd/tests/concurrent_close.cpp @@ -8,6 +8,7 @@ #include <fcntl.h> /* O_RDONLY */ #include <pthread.h> #include <unistd.h> /* close() */ +#include "config.h" /* Happens with two threads also */ #define THREAD_COUNT 256 @@ -32,7 +33,9 @@ int main() pthread_t threads[THREAD_COUNT]; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif for (i = 0; i < THREAD_COUNT; ++i) { r = pthread_create(&threads[i], &attr, thread, 0); if (r != 0) { diff --git a/drd/tests/concurrent_close.vgtest b/drd/tests/concurrent_close.vgtest index 19c339b647..cc7834d877 100644 --- a/drd/tests/concurrent_close.vgtest +++ b/drd/tests/concurrent_close.vgtest @@ -1,4 +1,4 @@ prereq: ./supported_libpthread -vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no --num-callers=3 +vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no --num-callers=6 prog: concurrent_close stderr_filter: filter_stderr diff --git a/drd/tests/filter_error_count b/drd/tests/filter_error_count.in similarity index 92% rename from drd/tests/filter_error_count rename to drd/tests/filter_error_count.in index 89dc2b40c7..782284d1c7 100755 --- a/drd/tests/filter_error_count +++ b/drd/tests/filter_error_count.in @@ -1,9 +1,11 @@ #!/bin/sh +SED=@SED@ + # Filter the error output of Valgrind such that only the line with the error # summary is kept. Bart Van Assche, February 26, 2008. -sed -n \ +$SED -n \ -e 's/^.*\(ERROR SUMMARY.*\) ([^()]*)$/\1/' \ -e 's/^\(ERROR SUMMARY: [0-9]* errors\).*$/\1/' \ -e '/ERROR SUMMARY/p' diff --git a/drd/tests/filter_error_summary b/drd/tests/filter_error_summary.in similarity index 62% rename from drd/tests/filter_error_summary rename to drd/tests/filter_error_summary.in index cdf703f2fd..76d7a6dade 100755 --- a/drd/tests/filter_error_summary +++ b/drd/tests/filter_error_summary.in @@ -1,6 +1,8 @@ #!/bin/sh +SED=@SED@ + # Filter the error output of Valgrind such that only the line with the error # summary is kept. Bart Van Assche, February 26, 2008. -sed -n -e 's/^.*\(ERROR SUMMARY.*\) ([^()]*)$/\1/' -e '/ERROR SUMMARY/p' +$SED -n -e 's/^.*\(ERROR SUMMARY.*\) ([^()]*)$/\1/' -e '/ERROR SUMMARY/p' diff --git a/drd/tests/filter_stderr b/drd/tests/filter_stderr.in similarity index 94% rename from drd/tests/filter_stderr rename to drd/tests/filter_stderr.in index f5c56a3541..aec1d60f5d 100755 --- a/drd/tests/filter_stderr +++ b/drd/tests/filter_stderr.in @@ -2,7 +2,9 @@ dir=`dirname $0` -sed -e "s:_pthread_start (in /usr/lib/libSystem.B.dylib):(within libpthread-?.?.so):" | +SED=@SED@ + +$SED -e "s:_pthread_start (in /usr/lib/libSystem.B.dylib):(within libpthread-?.?.so):" | $dir/../../tests/filter_stderr_basic | @@ -17,7 +19,7 @@ fi | # Remove line numbers referring to drd's source code. # Remove libpthread's version number. # Remove line numbers from stack traces. -sed \ +$SED \ -e "/^drd, a thread error detector$/d" \ -e "s/^Allocation context: stack of thread \([0-9]*\), offset -[0-9]*$/Allocation context: stack of thread \1, offset .../" \ -e "/^warning: evaluate_Dwarf3_Expr: unhandled DW_OP_.*/d" \ @@ -30,8 +32,10 @@ sed \ -e "/^Copyright (C) 2006-20.., and GNU GPL'd, by Bart Van Assche.$/d" \ -e "s/\([A-Za-z_]*\) (clone.S:[0-9]*)/\1 (in \/...libc...)/" \ -e "s/\([A-Za-z_]*\) (swapcontext.S:[0-9]*)/\1 (in \/...libc...)/" \ +-e "s/_swapcontext/swapcontext/" \ -e "s/[A-Za-z_]* (pthread_create.c:[0-9]*)/(within libpthread-?.?.so)/" \ -e "s/[A-Za-z_]* (in [^ ]*libpthread-[0-9.]*\.so)/(within libpthread-?.?.so)/" \ +-e "s/... (in \/lib\/libthr.so.3)/(within libpthread-?.?.so)/" \ -e "s:(within /lib[0-9]*/ld-[0-9.]*\.so):(within ld-?.?.so):" \ -e "s/was held during [0-9][0-9]*/was held during .../" \ -e "s: BSS section of [^<]*/: BSS section of :g" \ diff --git a/drd/tests/filter_stderr_and_thread_no_and_offset b/drd/tests/filter_stderr_and_thread_no_and_offset deleted file mode 100755 index b0e75a4a7e..0000000000 --- a/drd/tests/filter_stderr_and_thread_no_and_offset +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -./filter_stderr_and_thread_no \ -| sed "s/ is at offset [0-9]* from / is at offset ... from /" diff --git a/drd/tests/filter_stderr_and_thread_no_and_offset.in b/drd/tests/filter_stderr_and_thread_no_and_offset.in new file mode 100755 index 0000000000..095d44d66c --- /dev/null +++ b/drd/tests/filter_stderr_and_thread_no_and_offset.in @@ -0,0 +1,6 @@ +#!/bin/sh + +SED=@SED@ + +./filter_stderr_and_thread_no \ +| $SED "s/ is at offset [0-9]* from / is at offset ... from /" diff --git a/drd/tests/filter_thread_no b/drd/tests/filter_thread_no.in similarity index 82% rename from drd/tests/filter_thread_no rename to drd/tests/filter_thread_no.in index f70c7b6682..6fac735705 100755 --- a/drd/tests/filter_thread_no +++ b/drd/tests/filter_thread_no.in @@ -1,7 +1,9 @@ #! /bin/sh +SED=@SED@ + # Get rid of the numbers as these make some tests more scheduling sensitive # -- those where there are multiple threads which play interchangeable roles. grep -v "^Thread [0-9][0-9]*:$" | -sed -e "s:hread [0-9][0-9]*:hread x:g" \ +$SED -e "s:hread [0-9][0-9]*:hread x:g" \ -e "s:of thread [0-9][0-9]*$:of thread x:g" diff --git a/drd/tests/filter_xml_and_thread_no b/drd/tests/filter_xml_and_thread_no.in similarity index 55% rename from drd/tests/filter_xml_and_thread_no rename to drd/tests/filter_xml_and_thread_no.in index a9f7ac1af5..db64dd7742 100755 --- a/drd/tests/filter_xml_and_thread_no +++ b/drd/tests/filter_xml_and_thread_no.in @@ -1,5 +1,7 @@ #! /bin/sh +SED=@SED@ + ../../memcheck/tests/filter_xml | ./filter_thread_no | -sed 's/ vc: \[[0-9:, ]*\]/ vc: [ ... ]/g' +$SED 's/ vc: \[[0-9:, ]*\]/ vc: [ ... ]/g' diff --git a/drd/tests/pth_create_chain.c b/drd/tests/pth_create_chain.c index e0771243d9..add1b33f0a 100644 --- a/drd/tests/pth_create_chain.c +++ b/drd/tests/pth_create_chain.c @@ -7,6 +7,7 @@ #include <stdlib.h> #include <stdio.h> #include <pthread.h> +#include "config.h" static pthread_t s_thread[1000]; @@ -23,7 +24,9 @@ static void* thread_func(void* p) // std::cout << "create " << thread_count << std::endl; s_arg[thread_count] = thread_count; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif pthread_create(&s_thread[thread_count], &attr, thread_func, &s_arg[thread_count]); pthread_attr_destroy(&attr); @@ -47,7 +50,9 @@ int main(int argc, char** argv) thread_count--; // std::cout << "create " << thread_count << std::endl; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif pthread_create(&s_thread[thread_count], &attr, thread_func, &thread_count); pthread_attr_destroy(&attr); diff --git a/drd/tests/pth_detached3.c b/drd/tests/pth_detached3.c old mode 100644 new mode 100755 index efeb15b72d..eab8514ede --- a/drd/tests/pth_detached3.c +++ b/drd/tests/pth_detached3.c @@ -6,6 +6,10 @@ #include <stdio.h> #include <stdint.h> +#if defined(VGO_freebsd) +#include <sys/types.h> +#endif + static void* thread_func(void* arg) { return 0; @@ -22,7 +26,11 @@ int main(int argc, char** argv) pthread_detach(thread); /* Invoke pthread_detach() with an invalid thread ID. */ +#ifdef VGO_freebsd + pthread_detach((pthread_t)12345); +#else pthread_detach((pthread_t)((uintptr_t)thread + 8)); +#endif fprintf(stderr, "Finished.\n"); diff --git a/drd/tests/pth_detached3.stderr.exp-freebsd b/drd/tests/pth_detached3.stderr.exp-freebsd new file mode 100644 index 0000000000..870287d0fe --- /dev/null +++ b/drd/tests/pth_detached3.stderr.exp-freebsd @@ -0,0 +1,14 @@ + +pthread_detach(): invalid thread ID 0x........ + at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) + by 0x........: pthread_detach (drd_pthread_intercepts.c:?) + by 0x........: main (pth_detached3.c:26) + +pthread_detach(): invalid thread ID 0x........ + at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) + by 0x........: pthread_detach (drd_pthread_intercepts.c:?) + by 0x........: main (pth_detached3.c:30) + +Finished. + +ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) diff --git a/drd/tests/pth_detached3.stderr.exp2 b/drd/tests/pth_detached3.stderr.exp2 index e82dee14db..d5910d8ebb 100644 --- a/drd/tests/pth_detached3.stderr.exp2 +++ b/drd/tests/pth_detached3.stderr.exp2 @@ -2,12 +2,12 @@ pthread_detach(): invalid thread ID 0x........ at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) by 0x........: pthread_detach (drd_pthread_intercepts.c:?) - by 0x........: main (pth_detached3.c:22) + by 0x........: main (pth_detached3.c:26) pthread_detach(): invalid thread ID 0x........ at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) by 0x........: pthread_detach (drd_pthread_intercepts.c:?) - by 0x........: main (pth_detached3.c:25) + by 0x........: main (pth_detached3.c:32) Finished. diff --git a/drd/tests/pth_uninitialized_cond.vgtest b/drd/tests/pth_uninitialized_cond.vgtest index fe031397df..f0d9ac286b 100644 --- a/drd/tests/pth_uninitialized_cond.vgtest +++ b/drd/tests/pth_uninitialized_cond.vgtest @@ -1,3 +1,4 @@ prereq: test -e pth_uninitialized_cond && ./supported_libpthread vgopts: --read-var-info=yes --check-stack-var=yes prog: pth_uninitialized_cond +cleanup: rm -f vgcore.* diff --git a/drd/tests/recursive_mutex.stderr.exp-freebsd b/drd/tests/recursive_mutex.stderr.exp-freebsd new file mode 100644 index 0000000000..28c7a6d79f --- /dev/null +++ b/drd/tests/recursive_mutex.stderr.exp-freebsd @@ -0,0 +1,18 @@ + + +Non-recursive mutex. +second lock call failed ! +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: lock_twice (recursive_mutex.c:?) + by 0x........: main (recursive_mutex.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_trylock (drd_pthread_intercepts.c:?) + by 0x........: lock_twice (recursive_mutex.c:?) + by 0x........: main (recursive_mutex.c:?) + +second unlock call failed ! + +Done. + +ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/drd/tests/std_list.cpp b/drd/tests/std_list.cpp index 1f09164538..d266bba9cb 100644 --- a/drd/tests/std_list.cpp +++ b/drd/tests/std_list.cpp @@ -15,9 +15,34 @@ #include <string> #include <sstream> #include <list> +#if defined(__FreeBSD__) +#include <mutex> +#endif using namespace std; +#if defined(__FreeBSD__) +std::mutex g_mutex; + +// according to this +// https://stackoverflow.com/questions/4057319/is-setlocale-thread-safe-function +// setlocale is not thread safe, and indeed on FreeBSD +// a load of errors are generated if this is not guarded +void setlocale_wrapper() +{ + const std::lock_guard<std::mutex> lock(g_mutex); + setlocale(LC_ALL, "English"); +} + +#else + +void setlocale_wrapper() +{ + setlocale(LC_ALL, "English"); +} + +#endif + class SubTest { public: SubTest() { @@ -41,7 +66,7 @@ class Test { public: void setUp() { subTest = new SubTest(); - setlocale(LC_ALL, "English"); + setlocale_wrapper(); } void tearDown() { delete subTest; } diff --git a/drd/tests/std_string.cpp b/drd/tests/std_string.cpp old mode 100644 new mode 100755 index 266c93fa5b..63f94729aa --- a/drd/tests/std_string.cpp +++ b/drd/tests/std_string.cpp @@ -8,6 +8,9 @@ #include <string> #include <cstring> #include <pthread.h> +#if defined(__FreeBSD__) +#include <stdio.h> +#endif #include <stdlib.h> #include <unistd.h> diff --git a/drd/tests/std_thread2.supp b/drd/tests/std_thread2.supp index ae69e0ddd9..2e41bac503 100644 --- a/drd/tests/std_thread2.supp +++ b/drd/tests/std_thread2.supp @@ -19,3 +19,29 @@ fun:allocate_stack fun:pthread_create@@GLIBC_2.2* } +{ + drd-gcc-runtims + drd:ConflictingAccess + obj:/lib/libgcc_s.so.1 +} +{ + drd-iterate-phdr + drd:ConflictingAccess + fun:dl_iterate_phdr +} +{ + drd-unwind-cfa + drd:ConflictingAccess + fun:_Unwind_GetCFA +} +{ + drd-thr + drd:ConflictingAccess + obj:/lib/libthr.so.3 +} +{ + drd-rtld + drd:ConflictingAccess + obj:/libexec/ld-elf*.so.1 +} + diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-freebsd b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd new file mode 100644 index 0000000000..e7828fd403 --- /dev/null +++ b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd @@ -0,0 +1,49 @@ + +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 2: +Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 1: +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +--------------------- +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) + +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang new file mode 100644 index 0000000000..384fd5cf75 --- /dev/null +++ b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang @@ -0,0 +1,49 @@ + +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 2: +Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 1: +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:39) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +--------------------- +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) + +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:39) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 b/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 index 277705a548..9a6c0474f5 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 +++ b/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 @@ -1,59 +1,59 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:52) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: (below main) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) --------------------- Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:53) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: (below main) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) ERROR SUMMARY: 8 errors from 7 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc22_exit_w_lock.vgtest b/drd/tests/tc22_exit_w_lock.vgtest index f16c1dfe91..5edf4e5ffe 100644 --- a/drd/tests/tc22_exit_w_lock.vgtest +++ b/drd/tests/tc22_exit_w_lock.vgtest @@ -1,3 +1,4 @@ prereq: ./supported_libpthread && [ -e ../../helgrind/tests/tc22_exit_w_lock ] vgopts: --num-callers=3 -q prog: ../../helgrind/tests/tc22_exit_w_lock +cleanup: rm -f vgcore.* diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-freebsd b/drd/tests/tc23_bogus_condwait.stderr.exp-freebsd new file mode 100644 index 0000000000..8fbfa87eb2 --- /dev/null +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-freebsd @@ -0,0 +1,40 @@ + +Mutex not locked: mutex 0x........, recursion count 0, owner 0. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:79) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:59) + +The object at address 0x........ is not a mutex. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:82) +rwlock 0x........ was first observed at: + at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:62) + +Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:85) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:58) + +The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:85) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:58) + +Thread 2: +Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: grab_the_lock (tc23_bogus_condwait.c:47) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:58) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 b/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 index 753b589387..f2c8ad34cd 100644 --- a/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 @@ -1,93 +1,93 @@ The object at address 0x........ is not a mutex. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:69) + by 0x........: main (tc23_bogus_condwait.c:75) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:20) + by 0x........: rescue_me (tc23_bogus_condwait.c:24) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) Thread 1: Mutex not locked: mutex 0x........, recursion count 0, owner 0. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:72) + by 0x........: main (tc23_bogus_condwait.c:79) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:54) + by 0x........: main (tc23_bogus_condwait.c:59) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:24) + by 0x........: rescue_me (tc23_bogus_condwait.c:29) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:54) + by 0x........: main (tc23_bogus_condwait.c:59) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:75) + by 0x........: main (tc23_bogus_condwait.c:82) rwlock 0x........ was first observed at: at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:57) + by 0x........: main (tc23_bogus_condwait.c:62) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:28) + by 0x........: rescue_me (tc23_bogus_condwait.c:33) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) rwlock 0x........ was first observed at: at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:57) + by 0x........: main (tc23_bogus_condwait.c:62) Thread 1: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 2. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:78) + by 0x........: main (tc23_bogus_condwait.c:85) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:32) + by 0x........: rescue_me (tc23_bogus_condwait.c:37) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) Thread 1: The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:78) + by 0x........: main (tc23_bogus_condwait.c:85) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: grab_the_lock (tc23_bogus_condwait.c:42) + by 0x........: grab_the_lock (tc23_bogus_condwait.c:47) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) ERROR SUMMARY: 12 errors from 10 contexts (suppressed: 0 from 0) diff --git a/drd/tests/thread_name.vgtest b/drd/tests/thread_name.vgtest index 868f5f3c3b..acd7bc682f 100644 --- a/drd/tests/thread_name.vgtest +++ b/drd/tests/thread_name.vgtest @@ -1,3 +1,3 @@ -prereq: test -e thread_name && ./supported_libpthread +prereq: test -e thread_name && ./supported_libpthread && ! ../../tests/os_test freebsd vgopts: --read-var-info=yes --check-stack-var=yes --num-callers=3 prog: thread_name diff --git a/drd/tests/thread_name_freebsd.c b/drd/tests/thread_name_freebsd.c new file mode 100644 index 0000000000..0f4954ba7c --- /dev/null +++ b/drd/tests/thread_name_freebsd.c @@ -0,0 +1,63 @@ +/* Test whether assigning names to threads works properly. */ + +#define _GNU_SOURCE +#include <pthread.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> +#include "../../drd/drd.h" + + +#define NUM_THREADS 10 + + +static pthread_barrier_t s_barrier; +static pthread_mutex_t s_mutex; +static pthread_cond_t s_cond; +static int s_counter; + +static void* thread_func(void* argp) +{ + const int thread_num = (ptrdiff_t)(argp); + pthread_mutex_t invalid_mutex; + char thread_name[32]; + + snprintf(thread_name, sizeof(thread_name), + "thread_func instance %d", thread_num + 1); + ANNOTATE_THREAD_NAME(thread_name); + + pthread_barrier_wait(&s_barrier); + + pthread_mutex_lock(&s_mutex); + while (s_counter != thread_num) + pthread_cond_wait(&s_cond, &s_mutex); + fprintf(stderr, "\n%s\n\n", thread_name); + pthread_mutex_unlock(&invalid_mutex); + s_counter++; + pthread_cond_broadcast(&s_cond); + pthread_mutex_unlock(&s_mutex); + + return 0; +} + + +int main(int arg, char** argv) +{ + int i; + pthread_t tid[NUM_THREADS]; + + pthread_barrier_init(&s_barrier, NULL, NUM_THREADS); + pthread_mutex_init(&s_mutex, 0); + pthread_cond_init(&s_cond, 0); + + for (i = 0; i < NUM_THREADS; i++) + pthread_create(&tid[i], 0, thread_func, (void*)(ptrdiff_t)i); + + for (i = 0; i < NUM_THREADS; i++) + pthread_join(tid[i], 0); + + pthread_cond_destroy(&s_cond); + pthread_mutex_destroy(&s_mutex); + + return 0; +} diff --git a/drd/tests/thread_name_freebsd.stderr.exp b/drd/tests/thread_name_freebsd.stderr.exp new file mode 100644 index 0000000000..a96e14a4f5 --- /dev/null +++ b/drd/tests/thread_name_freebsd.stderr.exp @@ -0,0 +1,93 @@ + + +thread_func instance 1 + +Thread 2 (thread_func instance 1): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 2 + +Thread 3 (thread_func instance 2): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 3 + +Thread 4 (thread_func instance 3): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 4 + +Thread 5 (thread_func instance 4): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 5 + +Thread 6 (thread_func instance 5): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 6 + +Thread 7 (thread_func instance 6): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 7 + +Thread 8 (thread_func instance 7): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 8 + +Thread 9 (thread_func instance 8): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 9 + +Thread 10 (thread_func instance 9): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 10 + +Thread 11 (thread_func instance 10): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 0 from 0) diff --git a/drd/tests/thread_name_freebsd.vgtest b/drd/tests/thread_name_freebsd.vgtest new file mode 100644 index 0000000000..e6317acdab --- /dev/null +++ b/drd/tests/thread_name_freebsd.vgtest @@ -0,0 +1,3 @@ +prereq: ../../tests/os_test freebsd +vgopts: --read-var-info=yes --check-stack-var=yes --num-callers=3 +prog: thread_name_freebsd diff --git a/drd/tests/thread_name_xml.vgtest b/drd/tests/thread_name_xml.vgtest index c6cd1cafb0..4c8545e38b 100644 --- a/drd/tests/thread_name_xml.vgtest +++ b/drd/tests/thread_name_xml.vgtest @@ -1,4 +1,4 @@ -prereq: test -e thread_name && ./supported_libpthread +prereq: test -e thread_name && ./supported_libpthread && ! ../../tests/os_test freebsd vgopts: --read-var-info=yes --check-stack-var=yes --num-callers=3 --xml=yes --xml-fd=2 prog: thread_name stderr_filter: filter_thread_name_xml diff --git a/helgrind/tests/Makefile.am b/helgrind/tests/Makefile.am old mode 100644 new mode 100755 index ad1af191a1..cf7f76d46a --- a/helgrind/tests/Makefile.am +++ b/helgrind/tests/Makefile.am @@ -4,7 +4,9 @@ include $(top_srcdir)/Makefile.tool-tests.am dist_noinst_SCRIPTS = filter_stderr \ filter_stderr_solaris \ filter_helgrind \ - filter_xml + filter_xml \ + filter_freebsd.awk \ + filter_stderr_freebsd EXTRA_DIST = \ annotate_hbefore.vgtest annotate_hbefore.stdout.exp \ @@ -21,6 +23,7 @@ EXTRA_DIST = \ cond_timedwait_test.stderr.exp \ bar_bad.vgtest bar_bad.stdout.exp bar_bad.stderr.exp \ bar_bad.stderr.exp-destroy-hang \ + bar_bad.stderr.exp-freebsd \ bar_trivial.vgtest bar_trivial.stdout.exp bar_trivial.stderr.exp \ free_is_write.vgtest free_is_write.stdout.exp \ free_is_write.stderr.exp \ @@ -40,9 +43,11 @@ EXTRA_DIST = \ locked_vs_unlocked2.vgtest \ locked_vs_unlocked2.stderr.exp \ locked_vs_unlocked2.stdout.exp \ + locked_vs_unlocked2.stderr.exp-freebsd \ locked_vs_unlocked3.vgtest \ locked_vs_unlocked3.stderr.exp \ locked_vs_unlocked3.stdout.exp \ + locked_vs_unlocked3.stderr.exp-freebsd \ pth_barrier1.vgtest pth_barrier1.stdout.exp pth_barrier1.stderr.exp \ pth_barrier2.vgtest pth_barrier2.stdout.exp pth_barrier2.stderr.exp \ pth_barrier3.vgtest pth_barrier3.stdout.exp pth_barrier3.stderr.exp \ @@ -52,6 +57,7 @@ EXTRA_DIST = \ pth_cond_destroy_busy.vgtest pth_cond_destroy_busy.stderr.exp \ pth_cond_destroy_busy.stderr.exp-ppc64 \ pth_cond_destroy_busy.stderr.exp-solaris \ + pth_cond_destroy_busy.stderr.exp-freebsd \ pth_spinlock.vgtest pth_spinlock.stdout.exp pth_spinlock.stderr.exp \ rwlock_race.vgtest rwlock_race.stdout.exp rwlock_race.stderr.exp \ rwlock_test.vgtest rwlock_test.stdout.exp rwlock_test.stderr.exp \ @@ -72,16 +78,19 @@ EXTRA_DIST = \ tc06_two_races.stderr.exp \ tc06_two_races_xml.vgtest tc06_two_races_xml.stdout.exp \ tc06_two_races_xml.stderr.exp \ + tc06_two_races_xml.stderr.exp-freebsd \ tc07_hbl1.vgtest tc07_hbl1.stdout.exp tc07_hbl1.stderr.exp \ tc08_hbl2.vgtest tc08_hbl2.stdout.exp tc08_hbl2.stderr.exp \ tc09_bad_unlock.vgtest tc09_bad_unlock.stdout.exp \ tc09_bad_unlock.stderr.exp tc09_bad_unlock.stderr.exp-solaris \ + tc09_bad_unlock.stderr.exp-freebsd \ tc10_rec_lock.vgtest tc10_rec_lock.stdout.exp tc10_rec_lock.stderr.exp \ tc11_XCHG.vgtest tc11_XCHG.stdout.exp tc11_XCHG.stderr.exp \ tc12_rwl_trivial.vgtest tc12_rwl_trivial.stdout.exp \ tc12_rwl_trivial.stderr.exp \ tc12_rwl_trivial.stderr.exp-darwin970 \ tc12_rwl_trivial.stderr.exp-solaris \ + tc12_rwl_trivial.stderr.exp-freebsd \ tc13_laog1.vgtest tc13_laog1.stdout.exp tc13_laog1.stderr.exp \ tc14_laog_dinphils.vgtest tc14_laog_dinphils.stdout.exp \ tc14_laog_dinphils.stderr.exp \ @@ -96,6 +105,7 @@ EXTRA_DIST = \ tc18_semabuse.stderr.exp-linux-mips32 \ tc18_semabuse.stderr.exp-linux-mips32-b \ tc18_semabuse.stderr.exp-solaris \ + tc18_semabuse.stderr.exp-freebsd \ tc19_shadowmem.vgtest tc19_shadowmem.stdout.exp \ tc19_shadowmem.stderr.exp tc19_shadowmem.stderr.exp-mips32 \ tc19_shadowmem.stderr.exp-mips32-BE \ @@ -115,6 +125,7 @@ EXTRA_DIST = \ tc23_bogus_condwait.vgtest tc23_bogus_condwait.stdout.exp \ tc23_bogus_condwait.stderr.exp \ tc23_bogus_condwait.stderr.exp-mips32 \ + tc23_bogus_condwait.stderr.exp-freebsd \ tc24_nonzero_sem.vgtest tc24_nonzero_sem.stdout.exp \ tc24_nonzero_sem.stderr.exp \ tls_threads.vgtest tls_threads.stdout.exp \ diff --git a/helgrind/tests/bar_bad.c... [truncated message content] |