From 85bbe2853e813bbd83aa17bc17c2b73d82f6bc3e Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Thu, 7 Oct 2021 21:33:45 +0200 Subject: [PATCH] FreeBSD support, patch 5 drd and helgrind tests --- .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 +- ...lter_error_count => filter_error_count.in} | 4 +- ..._error_summary => filter_error_summary.in} | 4 +- drd/tests/{filter_stderr => filter_stderr.in} | 8 +- .../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 +- ..._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 +++ .../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 + .../tc23_bogus_condwait.stderr.exp-freebsd | 40 +++ .../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 + .../tests/bar_bad.stderr.exp-destroy-hang | 18 +- helgrind/tests/bar_bad.stderr.exp-freebsd | 58 ++++ helgrind/tests/filter_freebsd.awk | 148 +++++++++ .../tests/{filter_stderr => filter_stderr.in} | 20 +- helgrind/tests/filter_stderr_freebsd | 60 ++++ .../locked_vs_unlocked2.stderr.exp-freebsd | 44 +++ .../locked_vs_unlocked3.stderr.exp-freebsd | 34 +++ .../pth_cond_destroy_busy.stderr.exp-freebsd | 24 ++ .../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 ++--- .../tests/tc09_bad_unlock.stderr.exp-freebsd | 150 +++++++++ .../tests/tc09_bad_unlock.stderr.exp-solaris | 72 ++--- helgrind/tests/tc11_XCHG.c | 9 +- helgrind/tests/tc12_rwl_trivial.c | 2 +- .../tests/tc12_rwl_trivial.stderr.exp-freebsd | 31 ++ helgrind/tests/tc17_sembar.c | 5 +- .../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 +- .../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(-) mode change 100644 => 100755 drd/tests/Makefile.am create mode 100644 drd/tests/bar_bad.stderr.exp-freebsd create mode 100644 drd/tests/bar_bad_xml.stderr.exp-freebsd rename drd/tests/{filter_error_count => filter_error_count.in} (92%) rename drd/tests/{filter_error_summary => filter_error_summary.in} (62%) rename drd/tests/{filter_stderr => filter_stderr.in} (94%) delete mode 100755 drd/tests/filter_stderr_and_thread_no_and_offset create mode 100755 drd/tests/filter_stderr_and_thread_no_and_offset.in rename drd/tests/{filter_thread_no => filter_thread_no.in} (82%) rename drd/tests/{filter_xml_and_thread_no => filter_xml_and_thread_no.in} (55%) mode change 100644 => 100755 drd/tests/pth_detached3.c create mode 100644 drd/tests/pth_detached3.stderr.exp-freebsd create mode 100644 drd/tests/recursive_mutex.stderr.exp-freebsd mode change 100644 => 100755 drd/tests/std_string.cpp create mode 100644 drd/tests/tc09_bad_unlock.stderr.exp-freebsd create mode 100644 drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang create mode 100644 drd/tests/tc23_bogus_condwait.stderr.exp-freebsd create mode 100644 drd/tests/thread_name_freebsd.c create mode 100644 drd/tests/thread_name_freebsd.stderr.exp create mode 100644 drd/tests/thread_name_freebsd.vgtest mode change 100644 => 100755 helgrind/tests/Makefile.am create mode 100644 helgrind/tests/bar_bad.stderr.exp-freebsd create mode 100644 helgrind/tests/filter_freebsd.awk rename helgrind/tests/{filter_stderr => filter_stderr.in} (84%) create mode 100755 helgrind/tests/filter_stderr_freebsd create mode 100644 helgrind/tests/locked_vs_unlocked2.stderr.exp-freebsd create mode 100644 helgrind/tests/locked_vs_unlocked3.stderr.exp-freebsd create mode 100644 helgrind/tests/pth_cond_destroy_busy.stderr.exp-freebsd create mode 100644 helgrind/tests/tc06_two_races_xml.stderr.exp-freebsd create mode 100644 helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd create mode 100644 helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd create mode 100644 helgrind/tests/tc18_semabuse.stderr.exp-freebsd create mode 100644 helgrind/tests/tc23_bogus_condwait.stderr.exp-freebsd 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< // 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 @@ + + + + +4 +drd + + + ... + ... + ... + ... + + +... +... +drd + + + ... + + ./../../helgrind/tests/bar_bad + + + + + RUNNING + + + + +initialise a barrier with zero count + + 0x........ + ... + BarrierErr + pthread_barrier_init: 'count' argument is zero: barrier 0x........ + + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + + + + +initialise a barrier twice + + 0x........ + ... + BarrierErr + Barrier reinitialization: barrier 0x........ + + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + + + barrier +
0x........
+ + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + +
+
+ + +initialise a barrier which has threads waiting on it + + 0x........ + ... + BarrierErr + Barrier reinitialization: barrier 0x........ + + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + + + barrier +
0x........
+ + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + +
+
+ + +destroy a barrier that has waiting threads + + 0x........ + ... + BarrierErr + Destruction of a barrier with active waiters: barrier 0x........ + + + 0x........ + ... + pthread_barrier_destroy + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + + + barrier +
0x........
+ + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + +
+
+ + +destroy a barrier that was never initialised + + 0x........ + ... + BarrierErr + Destruction of barrier that is being waited upon: barrier 0x........ + + + 0x........ + ... + free + ... + vg_replace_malloc.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + + + barrier +
0x........
+ + + 0x........ + ... + pthread_barrier_init + ... + drd_pthread_intercepts.c + ... + + + 0x........ + ... + main + ... + bar_bad.c + ... + + +
+
+ + + + FINISHED + + + + + + ... + 0x........ + + + ... + 0x........ + + + ... + 0x........ + + + ... + 0x........ + + + ... + 0x........ + + + +... + +
+ 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 /* O_RDONLY */ #include #include /* 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 #include #include +#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 #include +#if defined(VGO_freebsd) +#include +#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 #include #include +#if defined(__FreeBSD__) +#include +#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 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 #include #include +#if defined(__FreeBSD__) +#include +#endif #include #include 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 +#include +#include +#include +#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 b/helgrind/tests/bar_bad.c index 0882b03a16..22f70cdfaf 100644 --- a/helgrind/tests/bar_bad.c +++ b/helgrind/tests/bar_bad.c @@ -8,6 +8,7 @@ #include #include #include +#include "config.h" void* child1 ( void* arg ) { @@ -95,7 +96,9 @@ int main ( void ) bar5 = malloc(sizeof(pthread_barrier_t)); assert(bar5); memset(bar5, 1, sizeof(*bar5)); +#if !defined(VGO_freebsd) pthread_barrier_destroy(bar5); +#endif /* now we need to clean up the mess .. But skip canceling threads. */ /* r= pthread_cancel(thr1); assert(!r); // drd doesn't like it. Just exit. diff --git a/helgrind/tests/bar_bad.stderr.exp-destroy-hang b/helgrind/tests/bar_bad.stderr.exp-destroy-hang index f76663fbae..931d197314 100644 --- a/helgrind/tests/bar_bad.stderr.exp-destroy-hang +++ b/helgrind/tests/bar_bad.stderr.exp-destroy-hang @@ -8,14 +8,14 @@ Thread #x is the program's root thread Thread #x: pthread_barrier_init: 'count' argument is zero at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:43) + by 0x........: main (bar_bad.c:44) ---------------------------------------------------------------- Thread #x's call to pthread_barrier_init failed with error code 22 (EINVAL: Invalid argument) at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:43) + by 0x........: main (bar_bad.c:44) initialise a barrier twice @@ -23,7 +23,7 @@ initialise a barrier twice Thread #x: pthread_barrier_init: barrier is already initialised at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:49) + by 0x........: main (bar_bad.c:50) initialise a barrier which has threads waiting on it @@ -31,13 +31,13 @@ initialise a barrier which has threads waiting on it Thread #x: pthread_barrier_init: barrier is already initialised at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:64) + by 0x........: main (bar_bad.c:65) ---------------------------------------------------------------- Thread #x: pthread_barrier_init: threads are waiting at barrier at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:64) + by 0x........: main (bar_bad.c:65) destroy a barrier that has waiting threads @@ -45,20 +45,20 @@ destroy a barrier that has waiting threads Thread #x: pthread_barrier_destroy: threads are waiting at barrier at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:82) + by 0x........: main (bar_bad.c:83) ---Thread-Announcement------------------------------------------ Thread #x was created ... by 0x........: pthread_create@* (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:76) + by 0x........: main (bar_bad.c:77) ---------------------------------------------------------------- Thread #x: pthread_barrier_wait: barrier is uninitialised at 0x........: pthread_barrier_wait (hg_intercepts.c:...) - by 0x........: sleep1 (bar_bad.c:22) + by 0x........: sleep1 (bar_bad.c:23) by 0x........: mythread_wrapper (hg_intercepts.c:...) ... @@ -68,5 +68,5 @@ destroy a barrier that was never initialised Thread #x: pthread_barrier_destroy: barrier was never initialised at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:98) + by 0x........: main (bar_bad.c:100) diff --git a/helgrind/tests/bar_bad.stderr.exp-freebsd b/helgrind/tests/bar_bad.stderr.exp-freebsd new file mode 100644 index 0000000000..838e3a2651 --- /dev/null +++ b/helgrind/tests/bar_bad.stderr.exp-freebsd @@ -0,0 +1,58 @@ + +initialise a barrier with zero count +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x: pthread_barrier_init: 'count' argument is zero + at 0x........: pthread_barrier_init (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:44) + +---------------------------------------------------------------- + +Thread #x's call to pthread_barrier_init failed + with error code 22 (EINVAL: Invalid argument) + at 0x........: pthread_barrier_init (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:44) + + +initialise a barrier twice +---------------------------------------------------------------- + +Thread #x: pthread_barrier_init: barrier is already initialised + at 0x........: pthread_barrier_init (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:50) + + +initialise a barrier which has threads waiting on it +---------------------------------------------------------------- + +Thread #x: pthread_barrier_init: barrier is already initialised + at 0x........: pthread_barrier_init (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:65) + +---------------------------------------------------------------- + +Thread #x: pthread_barrier_init: threads are waiting at barrier + at 0x........: pthread_barrier_init (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:65) + + +destroy a barrier that has waiting threads +---------------------------------------------------------------- + +Thread #x: pthread_barrier_destroy: threads are waiting at barrier + at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:83) + +---------------------------------------------------------------- + +Thread #x's call to pthread_barrier_destroy failed + with error code 16 (EBUSY: Device or resource busy) + at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) + by 0x........: main (bar_bad.c:83) + + +destroy a barrier that was never initialised diff --git a/helgrind/tests/filter_freebsd.awk b/helgrind/tests/filter_freebsd.awk new file mode 100644 index 0000000000..f7eadafe42 --- /dev/null +++ b/helgrind/tests/filter_freebsd.awk @@ -0,0 +1,148 @@ +/pthread_create_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_create \(hg_intercepts.c/)) { + print " by 0x........: pthread_create@* (hg_intercepts.c:...)"; + print; + } else { + sub(/pthread_create/, "pthread_create@*"); + print; + } + next; +} +/pthread_cond_timedwait_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_cond_timedwait \(hg_intercepts.c/)) { + print " by 0x........: pthread_cond_timedwait@* (hg_intercepts.c:...)"; + print; + } else { + sub(/pthread_cond_timedwait/, "pthread_cond_timedwait@*"); + print; + } + next; +} +/pthread_cond_wait_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_cond_wait \(hg_intercepts.c/)) { + print " by 0x........: pthread_cond_wait@* (hg_intercepts.c:...)"; + print; + } else { + sub(/pthread_cond_wait/, "pthread_cond_wait@*"); + print; + } + next; +} +/pthread_cond_destroy_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_cond_destroy \(hg_intercepts.c/)) { + print " by 0x........: pthread_cond_destroy@* (hg_intercepts.c:...)"; + print; + } else { + sub(/pthread_cond_destroy/, "pthread_cond_destroy@*"); + print; + } + next; +} +/pthread_cond_signal_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_cond_signal \(hg_intercepts.c/)) { + print " by 0x........: pthread_cond_signal (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/mutex_lock_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_mutex_lock \(hg_intercepts.c/)) { + print " by 0x........: pthread_mutex_lock (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/mutex_unlock_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_mutex_unlock \(hg_intercepts.c/)) { + print " by 0x........: pthread_mutex_unlock (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/pthread_rwlock_unlock_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_rwlock_unlock \(hg_intercepts.c/)) { + print " by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/pthread_rwlock_init_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /pthread_rwlock_init \(hg_intercepts.c/)) { + print " by 0x........: pthread_rwlock_init (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/sem_init_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /sem_init \(hg_intercepts.c/)) { + print " by 0x........: sem_init (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/sem_wait_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /sem_wait \(hg_intercepts.c/)) { + print " by 0x........: sem_wait (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/sem_post_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /sem_post \(hg_intercepts.c/)) { + print " by 0x........: sem_post (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +/sem_destroy_WRK \(hg_intercepts.c/ { + print; + getline; + if (!match($0, /sem_destroy \(hg_intercepts.c/)) { + print " by 0x........: sem_destroy (hg_intercepts.c:...)"; + print; + } else { + print; + } + next; +} +{print;} diff --git a/helgrind/tests/filter_stderr b/helgrind/tests/filter_stderr.in similarity index 84% rename from helgrind/tests/filter_stderr rename to helgrind/tests/filter_stderr.in index 6b85663bc0..9953b6527f 100755 --- a/helgrind/tests/filter_stderr +++ b/helgrind/tests/filter_stderr.in @@ -2,6 +2,8 @@ dir=`dirname $0` +SED=@SED@ + $dir/../../tests/filter_stderr_basic | # Anonymise addresses @@ -14,17 +16,25 @@ else cat fi | +# And FreeBSD +if $dir/../../tests/os_test freebsd; then + #perl -p $dir/filter_stderr_freebsd + awk -f $dir/filter_freebsd.awk +else + cat +fi | + # get rid of the numbers in bits of text "Thread #n", "thread #n", # "Thread n" and "thread n", "tid n" # as these make some tests more scheduling sensitive -- those where # there are multiple threads which play interchangeable roles. -sed \ +$SED \ -e "s/tid [0-9][0-9]*/tid #x/g" \ -e "s/hread #[0-9][0-9]*/hread #x/g" \ -e "s/hread [0-9][0-9]*/hread x/g" | # Likewise for frame numbers, which depend on compilation. -sed -e "s/frame #[0-9][0-9]*/frame #x/g" | \ +$SED -e "s/frame #[0-9][0-9]*/frame #x/g" | \ # Remove the message that more than hundred errors have been detected # (consists of two lines) and also the empty line above it. @@ -32,7 +42,7 @@ awk 'BEGIN{begin=1} {if ($0 == "More than 100 errors detected. Subsequent error # Merge sem_wait and sem_wait@*, as either could be used. Likewise for # sem_post. -sed \ +$SED \ -e "s/sem_wait@\*/sem_wait/" \ -e "s/sem_post@\*/sem_post/" | @@ -40,7 +50,7 @@ sed \ # also the standard postamble (does such a word exist?) # And also remove pthread_create_WRK lines, as ppc64 stacktraces # do not contain them (at least on gcc110/fedora18). -sed \ +$SED \ -e "/^Helgrind, a thread error detector/ , /./ d" \ -e "/^For lists of detected and suppressed errors, rerun with: -s$/d" \ -e "/^Use --history-level=approx or =none to gain increased speed, at$/d" \ @@ -48,7 +58,7 @@ sed \ -e "/pthread_create_WRK (hg_intercepts.c:/d" | # Some arches return ENOSYS instead of EINVAL for undefined futex operations. -sed -e "s/with error code 38 (ENOSYS: Function not implemented)/with error code 22 (EINVAL: Invalid argument)/" | +$SED -e "s/with error code 38 (ENOSYS: Function not implemented)/with error code 22 (EINVAL: Invalid argument)/" | $dir/../../helgrind/tests/filter_helgrind "$@" diff --git a/helgrind/tests/filter_stderr_freebsd b/helgrind/tests/filter_stderr_freebsd new file mode 100755 index 0000000000..7c89e04fb3 --- /dev/null +++ b/helgrind/tests/filter_stderr_freebsd @@ -0,0 +1,60 @@ +#!/usr/bin/env perl + +use warnings; +use strict; +use feature 'say'; + +# Replace pthread_create with pthread_create@* which is expected on Linux +s/pthread_create \(hg_intercepts.c:/pthread_create@* \(hg_intercepts.c:/g; + +# ditto pthread_cond_destroy +s/pthread_cond_destroy \(hg_intercepts.c:/pthread_cond_destroy@* \(hg_intercepts.c:/g; + +# ditto pthread_cond_timedwait +s/pthread_cond_timedwait \(hg_intercepts.c:/pthread_cond_timedwait@* \(hg_intercepts.c:/g; + +my @regex = ( + [" by 0x\.{8}: pthread_create_WRK \(hg_intercepts.c:[0-9]{3,4}\)", + " by 0x.{8}: pthread_create\@\* \(hg_intercepts.c:[0-9]{3,4}\)", + " by 0x........: pthread_create@* \(hg_intercepts.c:...\)" + ] + ); + +foreach my $item (@regex) { + my $just_saw_first_line; + + while (<>) { + + if ($just_saw_first_line and not /^$item->[1]/) { + say $item->[2]; + } + + $just_saw_first_line = /^$item->[0]/; + print + } +} + +# because of optimization, there's one less line in the callstack when VG is built with clang +# not this is a host difference, not a client one +#s/(0x........: pthread_create_WRK \(hg_intercepts.c:433\)\n)(?! by 0x........: pthread_create@\* \(hg_intercepts.c:472\))/$1 by 0x........: pthread_create@* (hg_intercepts.c:...)\n/; +#s/$ by 0x\.{8}: pthread_create_WRK \(hg_intercepts.c:[0-9]{3,4}\).(?! by 0x\.{8}: pthread_create@\* \(hg_intercepts.c:[0-9]{3,4}\))^/ by 0x........: pthread_create_WRK \(hg_intercepts.c:...\)\n by 0x........: pthread_create@* \(hg_intercepts.c:...\)\n/s; + +#s/0x\.{8}: pthread_destroy_WRK \(hg_intercepts.c:[0-9]+\).(?! by 0x[0-9A-F]+: pthread_destroy@\* \(hg_intercepts.c:[0-9]+\))/0x........: pthread_destroy_WRK \(hg_intercepts.c:...\)\n by 0x........: pthread_destroy@* \(hg_intercepts.c:...\)\n/gms; + +#s/0x\.{8}: pthread_cond_timedwait_WRK \(hg_intercepts.c:\.{3,4}\).(?! by 0x[0-9A-F]+: pthread_cond_timedwait@\* \(hg_intercepts.c:\.{3,4}\))/0x........: pthread_cond_timedwait_WRK \(hg_intercepts.c:...\)\n by 0x........: pthread_cond_timedwait@* \(hg_intercepts.c:...\)\n/gms; + +#s/0x\.{8}: mutex_lock_WRK \(hg_intercepts.c:[0-9]+\).(?! by 0x\.{8}: pthread_mutex_lock \(hg_intercepts.c:[0-9]+\))/0x........: mutex_lock_WRK \(hg_intercepts.c:...\)\n by 0x........: pthread_mutex_lock \(hg_intercepts.c:...\)\n/gms; + +#s/0x\.{8}: mutex_unlock_WRK \(hg_intercepts.c:.[0-9]+\).(?! by 0x\.{8}: pthread_mutex_unlock \(hg_intercepts.c:.[0-9]+\))/0x........: mutex_unlock_WRK \(hg_intercepts.c:...\)\n by 0x........: pthread_mutex_unlock \(hg_intercepts.c:...\)\n/gms; + +#s/0x\.{8}: pthread_cond_wait_WRK \(hg_intercepts.c:.[0-9]+\).(?! by 0x\.{8}: pthread_cond_wait \(hg_intercepts.c:.[0-9]+\))/0x........: pthread_cond_wait_WRK (hg_intercepts.c:...)\n by 0x........: pthread_cond_wait (hg_intercepts.c:...)\n/gms; + +#s/0x\.{8}: pthread_cond_signal_WRK \(hg_intercepts.c:[0-9]+\).(?! by 0x\.{8}: pthread_cond_signal \(hg_intercepts.c:....\))/0x........: pthread_cond_signal_WRK (hg_intercepts.c:...)\n by 0x........: pthread_cond_signal (hg_intercepts.c:...)\n/gms; + +#s/0x\.{8}: sem_init_WRK \(hg_intercepts.c:.[0-9]+\).(?! by 0x\.{8}: sem_init \(hg_intercepts.c:.[0-9]+\))/0x........: sem_init_WRK (hg_intercepts.c:...)\n by 0x........: sem_init (hg_intercepts.c:...)\n/gms; + +#s/0x\.{8}: sem_wait_WRK \(hg_intercepts.c:[0-9]+\).(?! by 0x\.{8}: sem_wait \(hg_intercepts.c:....\))/0x........: sem_wait_WRK (hg_intercepts.c:...)\n by 0x........: sem_wait (hg_intercepts.c:...)\n/gms; + +#s/0x\.{8}: sem_post_WRK \(hg_intercepts.c:[0-9]+\).(?! by 0x\.{8}: sem_post \(hg_intercepts.c:.[0-9]+\))/0x........: sem_post_WRK (hg_intercepts.c:...)\n by 0x........: sem_post (hg_intercepts.c:...)\n/gms; + +#s/0x\.{8}: sem_destroy_WRK \(hg_intercepts.c:[0-9]+\).(?! by 0x\.{8}: sem_destroy \(hg_intercepts.c:....\))/0x........: sem_destroy_WRK (hg_intercepts.c:...)\n by 0x........: sem_destroy (hg_intercepts.c:...)\n/gms; diff --git a/helgrind/tests/locked_vs_unlocked2.stderr.exp-freebsd b/helgrind/tests/locked_vs_unlocked2.stderr.exp-freebsd new file mode 100644 index 0000000000..c04588e5ac --- /dev/null +++ b/helgrind/tests/locked_vs_unlocked2.stderr.exp-freebsd @@ -0,0 +1,44 @@ +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked2.c:61) + +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked2.c:62) + +---------------------------------------------------------------- + + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked2.c:58) + Address 0x........ is 0 bytes inside data symbol "mx2a" + + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked2.c:59) + Address 0x........ is 0 bytes inside data symbol "mx2b" + + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked2.c:57) + Address 0x........ is 0 bytes inside data symbol "mx1b" + +Possible data race during write of size 4 at 0x........ by thread #x +Locks held: 2, at addresses 0x........ 0x........ + at 0x........: child_fn2 (locked_vs_unlocked2.c:44) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + +This conflicts with a previous write of size 4 by thread #x +Locks held: 2, at address 0x........ (and 1 that can't be shown) + at 0x........: child_fn1 (locked_vs_unlocked2.c:28) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + Address 0x........ is 0 bytes inside data symbol "x" + diff --git a/helgrind/tests/locked_vs_unlocked3.stderr.exp-freebsd b/helgrind/tests/locked_vs_unlocked3.stderr.exp-freebsd new file mode 100644 index 0000000000..75af898179 --- /dev/null +++ b/helgrind/tests/locked_vs_unlocked3.stderr.exp-freebsd @@ -0,0 +1,34 @@ +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked3.c:53) + +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked3.c:54) + +---------------------------------------------------------------- + + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: main (locked_vs_unlocked3.c:51) + Address 0x........ is 0 bytes inside data symbol "mx" + +Possible data race during write of size 4 at 0x........ by thread #x +Locks held: none + at 0x........: child_fn2 (locked_vs_unlocked3.c:38) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + +This conflicts with a previous write of size 4 by thread #x +Locks held: 1, at address 0x........ + at 0x........: child_fn1 (locked_vs_unlocked3.c:27) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + Address 0x........ is 0 bytes inside data symbol "x" + diff --git a/helgrind/tests/pth_cond_destroy_busy.stderr.exp-freebsd b/helgrind/tests/pth_cond_destroy_busy.stderr.exp-freebsd new file mode 100644 index 0000000000..6ffa3c2cd5 --- /dev/null +++ b/helgrind/tests/pth_cond_destroy_busy.stderr.exp-freebsd @@ -0,0 +1,24 @@ + +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x: pthread_cond_destroy: destruction of condition variable being waited upon + at 0x........: pthread_cond_destroy_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_destroy@* (hg_intercepts.c:...) + by 0x........: main (pth_cond_destroy_busy.c:52) + +---------------------------------------------------------------- + +Thread #x's call to pthread_cond_destroy failed + with error code 16 (EBUSY: Device or resource busy) + at 0x........: pthread_cond_destroy_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_destroy@* (hg_intercepts.c:...) + by 0x........: main (pth_cond_destroy_busy.c:52) + +First pthread_cond_destroy() call returned EBUSY. +Second pthread_cond_destroy() call returned success. + +ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/tc06_two_races_xml.stderr.exp-freebsd b/helgrind/tests/tc06_two_races_xml.stderr.exp-freebsd new file mode 100644 index 0000000000..65a79a759b --- /dev/null +++ b/helgrind/tests/tc06_two_races_xml.stderr.exp-freebsd @@ -0,0 +1,251 @@ + + + + +4 +helgrind + + + Helgrind, a thread error detector + Copyright (C) XXXX-YYYY, and GNU GPL'd, by OpenWorks LLP et al. + Using Valgrind-X.Y.X and LibVEX; rerun with -h for copyright info + Command: ./tc06_two_races + + +... +... +helgrind + + + + ... + --command-line-only=yes + --memcheck:leak-check=no + --tool=helgrind + --read-var-info=yes + --xml=yes + --xml-fd=2 + --log-file=/dev/null + + + ... + + + + + RUNNING + + + + + 1 + + + + + 2 + + ... + + 0x........ + ... + main + ... + tc06_two_races.c + 26 + + + + + + ... + ... + Race + + Possible data race during read of size 4 at 0x........ by thread #x + 1 + + + + 0x........ + ... + main + ... + tc06_two_races.c + 31 + + + + This conflicts with a previous write of size 4 by thread #x + 2 + + + + 0x........ + ... + child_fn + ... + tc06_two_races.c + 14 + + + 0x........ + ... + mythread_wrapper + ... + hg_intercepts.c + ... + + ... + + Location 0x........ is 0 bytes inside global var "unprot1" + declared at tc06_two_races.c:9 tc06_two_races.c 9 + + + + ... + ... + Race + + Possible data race during write of size 4 at 0x........ by thread #x + 1 + + + + 0x........ + ... + main + ... + tc06_two_races.c + 31 + + + + This conflicts with a previous write of size 4 by thread #x + 2 + + + + 0x........ + ... + child_fn + ... + tc06_two_races.c + 14 + + + 0x........ + ... + mythread_wrapper + ... + hg_intercepts.c + ... + + ... + + Location 0x........ is 0 bytes inside global var "unprot1" + declared at tc06_two_races.c:9 tc06_two_races.c 9 + + + + ... + ... + Race + + Possible data race during read of size 4 at 0x........ by thread #x + 1 + + + + 0x........ + ... + main + ... + tc06_two_races.c + 35 + + + + This conflicts with a previous write of size 4 by thread #x + 2 + + + + 0x........ + ... + child_fn + ... + tc06_two_races.c + 18 + + + 0x........ + ... + mythread_wrapper + ... + hg_intercepts.c + ... + + ... + + Location 0x........ is 0 bytes inside global var "unprot2" + declared at tc06_two_races.c:9 tc06_two_races.c 9 + + + + ... + ... + Race + + Possible data race during write of size 4 at 0x........ by thread #x + 1 + + + + 0x........ + ... + main + ... + tc06_two_races.c + 35 + + + + This conflicts with a previous write of size 4 by thread #x + 2 + + + + 0x........ + ... + child_fn + ... + tc06_two_races.c + 18 + + + 0x........ + ... + mythread_wrapper + ... + hg_intercepts.c + ... + + ... + + Location 0x........ is 0 bytes inside global var "unprot2" + declared at tc06_two_races.c:9 tc06_two_races.c 9 + + + + + FINISHED + + + +... + +... + + + diff --git a/helgrind/tests/tc07_hbl1.c b/helgrind/tests/tc07_hbl1.c index 3972b512ee..54297dee68 100644 --- a/helgrind/tests/tc07_hbl1.c +++ b/helgrind/tests/tc07_hbl1.c @@ -8,6 +8,8 @@ #undef PLAT_x86_darwin #undef PLAT_amd64_darwin +#undef PLAT_x86_freebsd +#undef PLAT_amd64_freebsd #undef PLAT_x86_linux #undef PLAT_amd64_linux #undef PLAT_ppc32_linux @@ -23,6 +25,10 @@ # define PLAT_x86_darwin 1 #elif defined(__APPLE__) && defined(__x86_64__) # define PLAT_amd64_darwin 1 +#elif defined(__FreeBSD__) && defined(__i386__) +# define PLAT_x86_freebsd 1 +#elif defined(__FreeBSD__) && defined(__amd64__) +# define PLAT_amd64_freebsd 1 #elif defined(__linux__) && defined(__i386__) # define PLAT_x86_linux 1 #elif defined(__linux__) && defined(__x86_64__) @@ -49,7 +55,8 @@ #if defined(PLAT_amd64_linux) || defined(PLAT_x86_linux) \ || defined(PLAT_amd64_darwin) || defined(PLAT_x86_darwin) \ - || defined(PLAT_amd64_solaris) || defined(PLAT_x86_solaris) + || defined(PLAT_amd64_solaris) || defined(PLAT_x86_solaris) \ + || defined(PLAT_amd64_freebsd) || defined(PLAT_x86_freebsd) # define INC(_lval,_lqual) \ __asm__ __volatile__ ( \ "lock ; incl (%0)" : /*out*/ : /*in*/"r"(&(_lval)) : "memory", "cc" ) diff --git a/helgrind/tests/tc08_hbl2.c b/helgrind/tests/tc08_hbl2.c index e84ecec4a1..c3a2ec7946 100644 --- a/helgrind/tests/tc08_hbl2.c +++ b/helgrind/tests/tc08_hbl2.c @@ -24,6 +24,8 @@ #undef PLAT_x86_darwin #undef PLAT_amd64_darwin +#undef PLAT_x86_freebsd +#undef PLAT_amd64_freebsd #undef PLAT_x86_linux #undef PLAT_amd64_linux #undef PLAT_ppc32_linux @@ -40,6 +42,10 @@ # define PLAT_x86_darwin 1 #elif defined(__APPLE__) && defined(__x86_64__) # define PLAT_amd64_darwin 1 +#elif defined(__FreeBSD__) && defined(__i386__) +# define PLAT_x86_freebsd 1 +#elif defined(__FreeBSD__) && defined(__amd64__) +# define PLAT_amd64_freebsd 1 #elif defined(__linux__) && defined(__i386__) # define PLAT_x86_linux 1 #elif defined(__linux__) && defined(__x86_64__) @@ -71,7 +77,8 @@ #if defined(PLAT_amd64_linux) || defined(PLAT_x86_linux) \ || defined(PLAT_amd64_darwin) || defined(PLAT_x86_darwin) \ - || defined(PLAT_amd64_solaris) || defined(PLAT_x86_solaris) + || defined(PLAT_amd64_solaris) || defined(PLAT_x86_solaris) \ + || defined(PLAT_amd64_freebsd) || defined(PLAT_x86_freebsd) # define INC(_lval,_lqual) \ __asm__ __volatile__ ( \ "lock ; incl (%0)" : /*out*/ : /*in*/"r"(&(_lval)) : "memory", "cc" ) diff --git a/helgrind/tests/tc09_bad_unlock.c b/helgrind/tests/tc09_bad_unlock.c index 238ce9bf65..9e4a8801d7 100644 --- a/helgrind/tests/tc09_bad_unlock.c +++ b/helgrind/tests/tc09_bad_unlock.c @@ -5,6 +5,7 @@ #include #include #include +#include "config.h" void* child_fn ( void* arg ) { @@ -37,8 +38,10 @@ void nearly_main ( void ) is reported in child_fn. */ pthread_join(child, NULL ); +#if !defined(VGO_freebsd) /* Unlocking a totally bogus lock. */ pthread_mutex_unlock( (pthread_mutex_t*) &bogus[50] ); /* ERROR */ +#endif /* Now we get a freeing-locked-lock error, since the stack frame is removed whilst mx2 is still locked. */ diff --git a/helgrind/tests/tc09_bad_unlock.stderr.exp b/helgrind/tests/tc09_bad_unlock.stderr.exp index a18450b9a8..1eeac5f4bd 100644 --- a/helgrind/tests/tc09_bad_unlock.stderr.exp +++ b/helgrind/tests/tc09_bad_unlock.stderr.exp @@ -8,14 +8,14 @@ Thread #x is the program's root thread Thread #x unlocked a not-locked lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---Thread-Announcement------------------------------------------ @@ -23,23 +23,23 @@ Thread #x unlocked a not-locked lock at 0x........ Thread #x was created ... by 0x........: pthread_create@* (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:35) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:36) + by 0x........: main (tc09_bad_unlock.c:52) ---------------------------------------------------------------- Thread #x unlocked lock at 0x........ currently held by thread #x at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: mythread_wrapper (hg_intercepts.c:...) ... Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---------------------------------------------------------------- @@ -47,8 +47,8 @@ Thread #x unlocked lock at 0x........ currently held by thread #x Thread #x unlocked an invalid lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) ---------------------------------------------------------------- @@ -56,8 +56,8 @@ Thread #x's call to pthread_mutex_unlock failed with error code 22 (EINVAL: Invalid argument) at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) --------------------- ---------------------------------------------------------------- @@ -65,14 +65,14 @@ Thread #x's call to pthread_mutex_unlock failed Thread #x unlocked a not-locked lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---------------------------------------------------------------- @@ -80,44 +80,44 @@ Thread #x unlocked a not-locked lock at 0x........ Thread #x: Attempt to re-lock a non-recursive lock I already hold at 0x........: mutex_lock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_lock (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:32) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:53) Lock was previously acquired at 0x........: mutex_lock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_lock (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:32) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:52) ---------------------------------------------------------------- Thread #x: Bug in libpthread: recursive write lock granted on mutex/wrlock which does not support recursion at 0x........: mutex_lock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_lock (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:32) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:53) ---Thread-Announcement------------------------------------------ Thread #x was created ... by 0x........: pthread_create@* (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:35) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:36) + by 0x........: main (tc09_bad_unlock.c:53) ---------------------------------------------------------------- Thread #x unlocked lock at 0x........ currently held by thread #x at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: mythread_wrapper (hg_intercepts.c:...) ... Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---------------------------------------------------------------- @@ -125,8 +125,8 @@ Thread #x unlocked lock at 0x........ currently held by thread #x Thread #x unlocked an invalid lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) ---------------------------------------------------------------- @@ -134,8 +134,8 @@ Thread #x's call to pthread_mutex_unlock failed with error code 22 (EINVAL: Invalid argument) at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) ---------------------------------------------------------------- diff --git a/helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd b/helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd new file mode 100644 index 0000000000..1053cbebf2 --- /dev/null +++ b/helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd @@ -0,0 +1,150 @@ + +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x unlocked a not-locked lock at 0x........ + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) + Address 0x........ is on thread #x's stack + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) + + +---------------------------------------------------------------- + +Thread #x's call to pthread_mutex_unlock failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) + +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:36) + by 0x........: main (tc09_bad_unlock.c:52) + +---------------------------------------------------------------- + +Thread #x unlocked lock at 0x........ currently held by thread #x + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + Address 0x........ is on thread #x's stack + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) + + +---------------------------------------------------------------- + +Thread #x's call to pthread_mutex_unlock failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + +--------------------- +---------------------------------------------------------------- + +Thread #x unlocked a not-locked lock at 0x........ + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) + Address 0x........ is on thread #x's stack + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) + + +---------------------------------------------------------------- + +Thread #x's call to pthread_mutex_unlock failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) + +---------------------------------------------------------------- + +Thread #x: Attempt to re-lock a non-recursive lock I already hold + at 0x........: mutex_lock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_lock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:53) + Lock was previously acquired + at 0x........: mutex_lock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_lock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:52) + +---------------------------------------------------------------- + +Thread #x: Bug in libpthread: recursive write lock granted on mutex/wrlock which does not support recursion + at 0x........: mutex_lock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_lock (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:53) + +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:36) + by 0x........: main (tc09_bad_unlock.c:53) + +---------------------------------------------------------------- + +Thread #x unlocked lock at 0x........ currently held by thread #x + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + Lock at 0x........ was first observed + at 0x........: pthread_mutex_init (hg_intercepts.c:...) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + Address 0x........ is on thread #x's stack + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) + + +---------------------------------------------------------------- + +Thread #x's call to pthread_mutex_unlock failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + +---------------------------------------------------------------- + +Thread #x: Exiting thread still holds 1 lock + ... + + +ERROR SUMMARY: 11 errors from 11 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/tc09_bad_unlock.stderr.exp-solaris b/helgrind/tests/tc09_bad_unlock.stderr.exp-solaris index 8baa420c87..c670b266cc 100644 --- a/helgrind/tests/tc09_bad_unlock.stderr.exp-solaris +++ b/helgrind/tests/tc09_bad_unlock.stderr.exp-solaris @@ -8,14 +8,14 @@ Thread #x is the program's root thread Thread #x unlocked a not-locked lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---Thread-Announcement------------------------------------------ @@ -23,23 +23,23 @@ Thread #x unlocked a not-locked lock at 0x........ Thread #x was created ... by 0x........: pthread_create@* (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:35) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:36) + by 0x........: main (tc09_bad_unlock.c:52) ---------------------------------------------------------------- Thread #x unlocked lock at 0x........ currently held by thread #x at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: mythread_wrapper (hg_intercepts.c:...) ... Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---------------------------------------------------------------- @@ -47,8 +47,8 @@ Thread #x unlocked lock at 0x........ currently held by thread #x Thread #x unlocked an invalid lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) ---------------------------------------------------------------- @@ -56,8 +56,8 @@ Thread #x's call to pthread_mutex_unlock failed with error code 1 (EPERM: Operation not permitted) at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) --------------------- ---------------------------------------------------------------- @@ -65,14 +65,14 @@ Thread #x's call to pthread_mutex_unlock failed Thread #x unlocked a not-locked lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---------------------------------------------------------------- @@ -80,44 +80,44 @@ Thread #x unlocked a not-locked lock at 0x........ Thread #x: Attempt to re-lock a non-recursive lock I already hold at 0x........: mutex_lock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_lock (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:32) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:53) Lock was previously acquired at 0x........: mutex_lock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_lock (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:32) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:52) ---------------------------------------------------------------- Thread #x: Bug in libpthread: recursive write lock granted on mutex/wrlock which does not support recursion at 0x........: mutex_lock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_lock (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:32) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:33) + by 0x........: main (tc09_bad_unlock.c:53) ---Thread-Announcement------------------------------------------ Thread #x was created ... by 0x........: pthread_create@* (hg_intercepts.c:...) - by 0x........: nearly_main (tc09_bad_unlock.c:35) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:36) + by 0x........: main (tc09_bad_unlock.c:53) ---------------------------------------------------------------- Thread #x unlocked lock at 0x........ currently held by thread #x at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_intercepts.c:...) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: mythread_wrapper (hg_intercepts.c:...) ... Lock at 0x........ was first observed at 0x........: pthread_mutex_init (hg_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) Address 0x........ is on thread #x's stack - in frame #x, created by nearly_main (tc09_bad_unlock.c:16) + in frame #x, created by nearly_main (tc09_bad_unlock.c:17) ---------------------------------------------------------------- @@ -125,8 +125,8 @@ Thread #x unlocked lock at 0x........ currently held by thread #x Thread #x unlocked an invalid lock at 0x........ at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) ---------------------------------------------------------------- @@ -134,8 +134,8 @@ Thread #x's call to pthread_mutex_unlock failed with error code 1 (EPERM: Operation not permitted) at 0x........: mutex_unlock_WRK (hg_intercepts.c:...) by 0x........: pthread_mutex_unlock (hg_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) ---------------------------------------------------------------- diff --git a/helgrind/tests/tc11_XCHG.c b/helgrind/tests/tc11_XCHG.c index 15167e87e8..f6ff1c9846 100644 --- a/helgrind/tests/tc11_XCHG.c +++ b/helgrind/tests/tc11_XCHG.c @@ -11,6 +11,8 @@ #undef PLAT_x86_darwin #undef PLAT_amd64_darwin +#undef PLAT_x86_freebsd +#undef PLAT_amd64_freebsd #undef PLAT_x86_linux #undef PLAT_amd64_linux #undef PLAT_ppc32_linux @@ -25,6 +27,10 @@ # define PLAT_x86_darwin 1 #elif defined(__APPLE__) && defined(__x86_64__) # define PLAT_amd64_darwin 1 +#elif defined(__FreeBSD__) && defined(__i386__) +# define PLAT_x86_freebsd 1 +#elif defined(__FreeBSD__) && defined(__amd64__) +# define PLAT_amd64_freebsd 1 #elif defined(__linux__) && defined(__i386__) # define PLAT_x86_linux 1 #elif defined(__linux__) && defined(__x86_64__) @@ -52,7 +58,8 @@ #if defined(PLAT_amd64_linux) || defined(PLAT_x86_linux) \ || defined(PLAT_amd64_darwin) || defined(PLAT_x86_darwin) \ - || defined(PLAT_amd64_solaris) || defined(PLAT_x86_solaris) + || defined(PLAT_amd64_solaris) || defined(PLAT_x86_solaris) \ + || defined(PLAT_amd64_freebsd) || defined(PLAT_x86_freebsd) # define XCHG_M_R(_addr,_lval) \ __asm__ __volatile__( \ "xchgl %0, %1" \ diff --git a/helgrind/tests/tc12_rwl_trivial.c b/helgrind/tests/tc12_rwl_trivial.c index a84428e018..35702ebb09 100644 --- a/helgrind/tests/tc12_rwl_trivial.c +++ b/helgrind/tests/tc12_rwl_trivial.c @@ -27,7 +27,7 @@ int main ( void ) /* this should fail - lock is unowned now */ r = pthread_rwlock_unlock( &rwl ); -#if defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) assert(r != 0); #else assert(r == 0); diff --git a/helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd b/helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd new file mode 100644 index 0000000000..69ffcf80e5 --- /dev/null +++ b/helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd @@ -0,0 +1,31 @@ + +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x unlocked a not-locked lock at 0x........ + at 0x........: pthread_rwlock_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...) + ... + by 0x........: main (tc12_rwl_trivial.c:29) + Lock at 0x........ was first observed + at 0x........: pthread_rwlock_init_WRK (hg_intercepts.c:...) + by 0x........: pthread_rwlock_init (hg_intercepts.c:...) + by 0x........: main (tc12_rwl_trivial.c:18) + Address 0x........ is on thread #x's stack + in frame #x, created by main (tc12_rwl_trivial.c:14) + + +---------------------------------------------------------------- + +Thread #x's call to pthread_rwlock_unlock failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: pthread_rwlock_unlock_WRK (hg_intercepts.c:...) + by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...) + ... + by 0x........: main (tc12_rwl_trivial.c:29) + + +ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/tc17_sembar.c b/helgrind/tests/tc17_sembar.c index 88a1fe5bb6..36412a07e2 100644 --- a/helgrind/tests/tc17_sembar.c +++ b/helgrind/tests/tc17_sembar.c @@ -4,6 +4,9 @@ #include #include #include +#if defined(VGO_freebsd) +# include +#endif /* This is really a test of semaphore handling (sem_{init,destroy,post,wait}). Using semaphores a barrier function is created. Helgrind-3.3 (p.k.a Thrcheck) does understand @@ -222,7 +225,7 @@ static sem_t* my_sem_init (char* identity, int pshared, unsigned count) { sem_t* s; -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) s = malloc(sizeof(*s)); if (s) { if (sem_init(s, pshared, count) < 0) { diff --git a/helgrind/tests/tc18_semabuse.stderr.exp-freebsd b/helgrind/tests/tc18_semabuse.stderr.exp-freebsd new file mode 100644 index 0000000000..6eacf900cc --- /dev/null +++ b/helgrind/tests/tc18_semabuse.stderr.exp-freebsd @@ -0,0 +1,40 @@ + +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x's call to sem_init failed + with error code 22 (EINVAL: Invalid argument) + at 0x........: sem_init_WRK (hg_intercepts.c:...) + by 0x........: sem_init (hg_intercepts.c:...) + by 0x........: main (tc18_semabuse.c:23) + +---------------------------------------------------------------- + +Thread #x's call to sem_wait failed + with error code 22 (EINVAL: Invalid argument) + at 0x........: sem_wait_WRK (hg_intercepts.c:...) + by 0x........: sem_wait (hg_intercepts.c:...) + by 0x........: main (tc18_semabuse.c:34) + +---------------------------------------------------------------- + +Thread #x's call to sem_post failed + with error code 22 (EINVAL: Invalid argument) + at 0x........: sem_post_WRK (hg_intercepts.c:...) + by 0x........: sem_post (hg_intercepts.c:...) + ... + by 0x........: main (tc18_semabuse.c:40) + +---------------------------------------------------------------- + +Thread #x's call to sem_destroy failed + with error code 22 (EINVAL: Invalid argument) + at 0x........: sem_destroy_WRK (hg_intercepts.c:...) + by 0x........: sem_destroy (hg_intercepts.c:...) + by 0x........: main (tc18_semabuse.c:42) + + +ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/tc20_verifywrap.c b/helgrind/tests/tc20_verifywrap.c index c110000791..ae97bde8d3 100644 --- a/helgrind/tests/tc20_verifywrap.c +++ b/helgrind/tests/tc20_verifywrap.c @@ -18,7 +18,7 @@ #include "safe-pthread.h" #include "safe-semaphore.h" -#if !defined(__APPLE__) +#if !defined(__APPLE__) && !defined(__FreeBSD__) #if defined(__sun__) /* Fake __GLIBC_PREREQ on Solaris. Pretend glibc >= 2.4. */ diff --git a/helgrind/tests/tc20_verifywrap.vgtest b/helgrind/tests/tc20_verifywrap.vgtest index 0ee9c143d9..cde1b21751 100644 --- a/helgrind/tests/tc20_verifywrap.vgtest +++ b/helgrind/tests/tc20_verifywrap.vgtest @@ -1,3 +1,3 @@ -prereq: test -e tc20_verifywrap +prereq: test -e tc20_verifywrap && ! ../../tests/os_test freebsd prog: tc20_verifywrap vgopts: --read-var-info=yes --sigill-diagnostics=no diff --git a/helgrind/tests/tc22_exit_w_lock.vgtest b/helgrind/tests/tc22_exit_w_lock.vgtest index 2471541bab..2e6190a727 100644 --- a/helgrind/tests/tc22_exit_w_lock.vgtest +++ b/helgrind/tests/tc22_exit_w_lock.vgtest @@ -1,2 +1,3 @@ prereq: test -e tc22_exit_w_lock prog: tc22_exit_w_lock +cleanup: rm -f vgcore.* diff --git a/helgrind/tests/tc23_bogus_condwait.c b/helgrind/tests/tc23_bogus_condwait.c index 6ea5ad90be..f2ccf3517f 100644 --- a/helgrind/tests/tc23_bogus_condwait.c +++ b/helgrind/tests/tc23_bogus_condwait.c @@ -7,6 +7,9 @@ #include #include #include +#if defined(VGO_freebsd) +#include +#endif pthread_mutex_t mx[4]; pthread_cond_t cv; pthread_rwlock_t rwl; sem_t* quit_now; @@ -15,9 +18,11 @@ static int my_sem_destroy(sem_t*); static int my_sem_wait(sem_t*); static int my_sem_post(sem_t*); void* rescue_me ( void* uu ) { +#if !defined(VGO_freebsd) /* wait for, and unblock, the first wait */ sleep(1); pthread_cond_signal( &cv ); +#endif /* wait for, and unblock, the second wait */ sleep(1); @@ -65,8 +70,10 @@ int main ( void ) /* Do stupid things and hope that rescue_me gets us out of trouble */ +#if !defined(VGO_freebsd) /* mx is bogus */ r= pthread_cond_wait(&cv, (pthread_mutex_t*)(4 + (char*)&mx[0]) ); +#endif /* mx is not locked */ r= pthread_cond_wait(&cv, &mx[3]); @@ -98,7 +105,7 @@ static sem_t* my_sem_init (char* identity, int pshared, unsigned count) { sem_t* s; -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) s = malloc(sizeof(*s)); if (s) { if (sem_init(s, pshared, count) < 0) { diff --git a/helgrind/tests/tc23_bogus_condwait.stderr.exp b/helgrind/tests/tc23_bogus_condwait.stderr.exp index a6e6df3f5c..e1611a5d8f 100644 --- a/helgrind/tests/tc23_bogus_condwait.stderr.exp +++ b/helgrind/tests/tc23_bogus_condwait.stderr.exp @@ -8,49 +8,49 @@ Thread #x is the program's root thread Thread #x: pthread_cond_{timed}wait called with invalid mutex at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:69) + by 0x........: main (tc23_bogus_condwait.c:75) ---------------------------------------------------------------- Thread #x: pthread_cond_{timed}wait called with un-held mutex at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:72) + by 0x........: main (tc23_bogus_condwait.c:79) ---------------------------------------------------------------- Thread #x: pthread_cond_{timed}wait: cond is associated with a different mutex at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:72) + by 0x........: main (tc23_bogus_condwait.c:79) ---------------------------------------------------------------- Thread #x: pthread_cond_{timed}wait called with mutex of type pthread_rwlock_t* at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:75) + by 0x........: main (tc23_bogus_condwait.c:82) ---------------------------------------------------------------- Thread #x: pthread_cond_{timed}wait: cond is associated with a different mutex at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:75) + by 0x........: main (tc23_bogus_condwait.c:82) ---------------------------------------------------------------- Thread #x: pthread_cond_{timed}wait called with mutex held by a different thread at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:78) + by 0x........: main (tc23_bogus_condwait.c:85) ---------------------------------------------------------------- Thread #x: pthread_cond_{timed}wait: cond is associated with a different mutex at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) - by 0x........: main (tc23_bogus_condwait.c:78) + by 0x........: main (tc23_bogus_condwait.c:85) ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/tc23_bogus_condwait.stderr.exp-freebsd b/helgrind/tests/tc23_bogus_condwait.stderr.exp-freebsd new file mode 100644 index 0000000000..1eee38a90e --- /dev/null +++ b/helgrind/tests/tc23_bogus_condwait.stderr.exp-freebsd @@ -0,0 +1,100 @@ + +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{timed}wait called with un-held mutex + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:79) + +---------------------------------------------------------------- + +Thread #x's call to pthread_cond_wait failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:79) + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{timed}wait called with mutex of type pthread_rwlock_t* + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:82) + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{timed}wait: cond is associated with a different mutex + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:82) + +---------------------------------------------------------------- + +Thread #x's call to pthread_cond_wait failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:82) + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{timed}wait called with mutex held by a different thread + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:85) + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{timed}wait: cond is associated with a different mutex + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:85) + +---------------------------------------------------------------- + +Thread #x's call to pthread_cond_wait failed + with error code 1 (EPERM: Operation not permitted) + at 0x........: pthread_cond_wait_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_wait@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:85) + +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + by 0x........: main (tc23_bogus_condwait.c:69) + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{signal,broadcast}: dubious: associated lock is not held by any thread + at 0x........: pthread_cond_signal_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_signal (hg_intercepts.c:...) + by 0x........: rescue_me (tc23_bogus_condwait.c:29) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{signal,broadcast}: dubious: associated lock is not held by any thread + at 0x........: pthread_cond_signal_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_signal (hg_intercepts.c:...) + by 0x........: rescue_me (tc23_bogus_condwait.c:33) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{signal,broadcast}: dubious: associated lock is not held by any thread + at 0x........: pthread_cond_signal_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_signal (hg_intercepts.c:...) + by 0x........: rescue_me (tc23_bogus_condwait.c:37) + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + + +ERROR SUMMARY: 11 errors from 11 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/tc24_nonzero_sem.c b/helgrind/tests/tc24_nonzero_sem.c index bcd467ccbd..541fa7ddb8 100644 --- a/helgrind/tests/tc24_nonzero_sem.c +++ b/helgrind/tests/tc24_nonzero_sem.c @@ -9,6 +9,9 @@ #include #include #include +#if defined(VGO_freebsd) +# include +#endif #define N_THREADS 3 @@ -50,7 +53,7 @@ static sem_t* my_sem_init (char* identity, int pshared, unsigned count) { sem_t* s; -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) s = malloc(sizeof(*s)); if (s) { if (sem_init(s, pshared, count) < 0) { diff --git a/tests/check_makefile_consistency b/tests/check_makefile_consistency index 3e0ae4cbc6..c51e26ce26 100755 --- a/tests/check_makefile_consistency +++ b/tests/check_makefile_consistency @@ -84,7 +84,7 @@ do fi done - for f in $(ls -d filter* 2>/dev/null) + for f in $(ls -d filter* 2>/dev/null | grep -v \.in) do if ! echo "${parsed_makefile}" 2>/dev/null | grep '^ *dist_noinst_SCRIPTS *=' | grep -qw "$f" diff --git a/tests/os_test.c b/tests/os_test.c index d3c5a69d04..7e47bf0ce4 100644 --- a/tests/os_test.c +++ b/tests/os_test.c @@ -24,6 +24,7 @@ char* all_OSes[] = { "linux", "darwin", "solaris", + "freebsd", NULL }; @@ -66,6 +67,9 @@ static Bool go(char* OS, char *min_version) #elif defined(VGO_solaris) if ( 0 == strcmp( OS, "solaris" ) ) return True; +#elif defined(VGO_freebsd) + if ( 0 == strcmp( OS, "freebsd" ) ) return True; + #else # error Unknown OS #endif // VGO_* -- 2.47.2