]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD support, patch 5
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 7 Oct 2021 19:33:45 +0000 (21:33 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 7 Oct 2021 19:33:45 +0000 (21:33 +0200)
drd and helgrind tests

67 files changed:
.gitignore
configure.ac
drd/tests/Makefile.am [changed mode: 0644->0755]
drd/tests/annotate_smart_pointer.cpp
drd/tests/bar_bad.stderr.exp-freebsd [new file with mode: 0644]
drd/tests/bar_bad_xml.stderr.exp-freebsd [new file with mode: 0644]
drd/tests/circular_buffer.c
drd/tests/concurrent_close.cpp
drd/tests/concurrent_close.vgtest
drd/tests/filter_error_count.in [moved from drd/tests/filter_error_count with 92% similarity]
drd/tests/filter_error_summary.in [moved from drd/tests/filter_error_summary with 62% similarity]
drd/tests/filter_stderr.in [moved from drd/tests/filter_stderr with 94% similarity]
drd/tests/filter_stderr_and_thread_no_and_offset [deleted file]
drd/tests/filter_stderr_and_thread_no_and_offset.in [new file with mode: 0755]
drd/tests/filter_thread_no.in [moved from drd/tests/filter_thread_no with 82% similarity]
drd/tests/filter_xml_and_thread_no.in [moved from drd/tests/filter_xml_and_thread_no with 55% similarity]
drd/tests/pth_create_chain.c
drd/tests/pth_detached3.c [changed mode: 0644->0755]
drd/tests/pth_detached3.stderr.exp-freebsd [new file with mode: 0644]
drd/tests/pth_detached3.stderr.exp2
drd/tests/pth_uninitialized_cond.vgtest
drd/tests/recursive_mutex.stderr.exp-freebsd [new file with mode: 0644]
drd/tests/std_list.cpp
drd/tests/std_string.cpp [changed mode: 0644->0755]
drd/tests/std_thread2.supp
drd/tests/tc09_bad_unlock.stderr.exp-freebsd [new file with mode: 0644]
drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang [new file with mode: 0644]
drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8
drd/tests/tc22_exit_w_lock.vgtest
drd/tests/tc23_bogus_condwait.stderr.exp-freebsd [new file with mode: 0644]
drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86
drd/tests/thread_name.vgtest
drd/tests/thread_name_freebsd.c [new file with mode: 0644]
drd/tests/thread_name_freebsd.stderr.exp [new file with mode: 0644]
drd/tests/thread_name_freebsd.vgtest [new file with mode: 0644]
drd/tests/thread_name_xml.vgtest
helgrind/tests/Makefile.am [changed mode: 0644->0755]
helgrind/tests/bar_bad.c
helgrind/tests/bar_bad.stderr.exp-destroy-hang
helgrind/tests/bar_bad.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/filter_freebsd.awk [new file with mode: 0644]
helgrind/tests/filter_stderr.in [moved from helgrind/tests/filter_stderr with 84% similarity]
helgrind/tests/filter_stderr_freebsd [new file with mode: 0755]
helgrind/tests/locked_vs_unlocked2.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/locked_vs_unlocked3.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/pth_cond_destroy_busy.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/tc06_two_races_xml.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/tc07_hbl1.c
helgrind/tests/tc08_hbl2.c
helgrind/tests/tc09_bad_unlock.c
helgrind/tests/tc09_bad_unlock.stderr.exp
helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/tc09_bad_unlock.stderr.exp-solaris
helgrind/tests/tc11_XCHG.c
helgrind/tests/tc12_rwl_trivial.c
helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/tc17_sembar.c
helgrind/tests/tc18_semabuse.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/tc20_verifywrap.c
helgrind/tests/tc20_verifywrap.vgtest
helgrind/tests/tc22_exit_w_lock.vgtest
helgrind/tests/tc23_bogus_condwait.c
helgrind/tests/tc23_bogus_condwait.stderr.exp
helgrind/tests/tc23_bogus_condwait.stderr.exp-freebsd [new file with mode: 0644]
helgrind/tests/tc24_nonzero_sem.c
tests/check_makefile_consistency
tests/os_test.c

index 86962b47809a328bc53d5d050ea21a92e37b30b1..ac16d3638a3ec8f0b31a6288ba1393dc2ada4dde 100644 (file)
 /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
 /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
index c05994516f6ce1f6610c695ac37b813f0f3c6cb6..7e6773606de035105b74dca129f33129a4b4d580 100755 (executable)
@@ -5215,6 +5215,20 @@ AC_CONFIG_FILES([tests/filter_stderr_basic],
                 [chmod +x tests/filter_stderr_basic])
 AC_CONFIG_FILES([tests/filter_discards],
                 [chmod +x tests/filter_discards])
+AC_CONFIG_FILES([drd/tests/filter_stderr],
+                [chmod +x drd/tests/filter_stderr])
+AC_CONFIG_FILES([drd/tests/filter_error_count],
+                [chmod +x drd/tests/filter_error_count])
+AC_CONFIG_FILES([drd/tests/filter_error_summary],
+                [chmod +x drd/tests/filter_error_summary])
+AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
+                [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
+AC_CONFIG_FILES([drd/tests/filter_thread_no],
+                [chmod +x drd/tests/filter_thread_no])
+AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
+                [chmod +x drd/tests/filter_xml_and_thread_no])
+AC_CONFIG_FILES([helgrind/tests/filter_stderr],
+                [chmod +x helgrind/tests/filter_stderr])
 AC_OUTPUT
 
 cat<<EOF
old mode 100644 (file)
new mode 100755 (executable)
index 07650ef..4cb2f7f
@@ -87,10 +87,12 @@ EXTRA_DIST =                                        \
        bar_bad.stderr.exp                          \
        bar_bad.stderr.exp-nohang                   \
        bar_bad.stderr.exp-solaris                  \
+       bar_bad.stderr.exp-freebsd                  \
        bar_bad.vgtest                              \
        bar_bad_xml.stderr.exp                      \
        bar_bad_xml.stderr.exp-nohang               \
        bar_bad_xml.stderr.exp-solaris              \
+       bar_bad_xml.stderr.exp-freebsd              \
        bar_bad_xml.vgtest                          \
        bar_trivial.stderr.exp                      \
        bar_trivial.stdout.exp                      \
@@ -213,6 +215,7 @@ EXTRA_DIST =                                        \
        pth_detached2.vgtest                        \
        pth_detached3.stderr.exp1                   \
        pth_detached3.stderr.exp2                   \
+       pth_detached3.stderr.exp-freebsd            \
        pth_detached3.vgtest                        \
        pth_detached_sem.stderr.exp                 \
        pth_detached_sem.stdout.exp                 \
@@ -235,6 +238,7 @@ EXTRA_DIST =                                        \
        recursive_mutex.stderr.exp-linux            \
        recursive_mutex.stderr.exp-darwin           \
        recursive_mutex.stderr.exp-solaris          \
+       recursive_mutex.stderr.exp-freebsd          \
        recursive_mutex.vgtest                      \
        rwlock_race.stderr.exp                      \
        rwlock_race.stderr.exp2                     \
@@ -313,6 +317,8 @@ EXTRA_DIST =                                        \
        tc09_bad_unlock.stderr.exp-glibc2.8         \
        tc09_bad_unlock.stderr.exp-s390             \
        tc09_bad_unlock.stderr.exp-solaris          \
+       tc09_bad_unlock.stderr.exp-freebsd          \
+       tc09_bad_unlock.stderr.exp-freebsd-clang    \
        tc09_bad_unlock.vgtest                      \
        tc10_rec_lock.stderr.exp                    \
        tc10_rec_lock.vgtest                        \
@@ -345,6 +351,7 @@ EXTRA_DIST =                                        \
        tc23_bogus_condwait.stderr.exp-linux-ppc    \
        tc23_bogus_condwait.stderr.exp-darwin-x86   \
        tc23_bogus_condwait.stderr.exp-darwin-amd64 \
+       tc23_bogus_condwait.stderr.exp-freebsd      \
        tc23_bogus_condwait.vgtest                  \
        tc24_nonzero_sem.stderr.exp                 \
        tc24_nonzero_sem.vgtest                     \
@@ -352,6 +359,8 @@ EXTRA_DIST =                                        \
        thread_name.vgtest                          \
        thread_name_xml.stderr.exp                  \
        thread_name_xml.vgtest                      \
+       thread_name_freebsd.stderr.exp              \
+       thread_name_freebsd.vgtest                  \
        threaded-fork.stderr.exp                    \
        threaded-fork.vgtest                        \
        threaded-fork-vcs.stderr.exp                \
@@ -410,7 +419,11 @@ check_PROGRAMS =      \
   threaded-fork       \
   trylock             \
   unit_bitmap         \
-  unit_vc
+  unit_vc             \
+  std_atomic          \
+  std_list            \
+  std_mutex          \
+  std_string
 
 if HAVE_BOOST_1_35
 check_PROGRAMS += boost_thread
@@ -440,10 +453,6 @@ endif
 if CXX_CAN_INCLUDE_THREAD_HEADER
 if HAVE_SHARED_POINTER_ANNOTATION
 check_PROGRAMS += \
-  std_atomic      \
-  std_list        \
-  std_mutex      \
-  std_string      \
   std_thread      \
   std_thread2
 endif
@@ -480,6 +489,10 @@ if !VGCONF_OS_IS_DARWIN
 check_PROGRAMS += sem_wait
 endif
 
+if VGCONF_OS_IS_FREEBSD
+check_PROGRAMS += thread_name_freebsd
+endif
+
 
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ -Wno-inline -Wno-unused-parameter
 AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ @FLAG_FALIGNED_NEW@ \
index ccefc4735090cab2a11253f49d0117bd2b97524c..a6c1a9d52402a1a47befa8476465a612c7bfa1fb 100644 (file)
@@ -37,6 +37,7 @@
 #include <pthread.h>   // pthread_mutex_t
 #endif
 #include "unified_annotations.h"
+#include "config.h"
 
 
 static bool s_enable_annotations;
@@ -142,7 +143,9 @@ public:
   {
     pthread_attr_t attr;
     pthread_attr_init(&attr);
+#if !defined(VGO_freebsd)
     pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 4096);
+#endif
     pthread_create(&m_tid, &attr, pf, arg);
     pthread_attr_destroy(&attr);
   }
diff --git a/drd/tests/bar_bad.stderr.exp-freebsd b/drd/tests/bar_bad.stderr.exp-freebsd
new file mode 100644 (file)
index 0000000..00276e4
--- /dev/null
@@ -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 (file)
index 0000000..24ac7fe
--- /dev/null
@@ -0,0 +1,286 @@
+<?xml version="1.0"?>
+
+<valgrindoutput>
+
+<protocolversion>4</protocolversion>
+<protocoltool>drd</protocoltool>
+
+<preamble>
+  <line>...</line>
+  <line>...</line>
+  <line>...</line>
+  <line>...</line>
+</preamble>
+
+<pid>...</pid>
+<ppid>...</ppid>
+<tool>drd</tool>
+
+<args>
+  <vargv>...</vargv>
+  <argv>
+    <exe>./../../helgrind/tests/bar_bad</exe>
+  </argv>
+</args>
+
+<status>
+  <state>RUNNING</state>
+  <time>...</time>
+</status>
+
+
+initialise a barrier with zero count
+<error>
+  <unique>0x........</unique>
+  <tid>...</tid>
+  <kind>BarrierErr</kind>
+  <what>pthread_barrier_init: 'count' argument is zero: barrier 0x........</what>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+</error>
+
+
+initialise a barrier twice
+<error>
+  <unique>0x........</unique>
+  <tid>...</tid>
+  <kind>BarrierErr</kind>
+  <what>Barrier reinitialization: barrier 0x........</what>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  <first_observed_at>
+    <what>barrier</what>
+    <address>0x........</address>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  </first_observed_at>
+</error>
+
+
+initialise a barrier which has threads waiting on it
+<error>
+  <unique>0x........</unique>
+  <tid>...</tid>
+  <kind>BarrierErr</kind>
+  <what>Barrier reinitialization: barrier 0x........</what>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  <first_observed_at>
+    <what>barrier</what>
+    <address>0x........</address>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  </first_observed_at>
+</error>
+
+
+destroy a barrier that has waiting threads
+<error>
+  <unique>0x........</unique>
+  <tid>...</tid>
+  <kind>BarrierErr</kind>
+  <what>Destruction of a barrier with active waiters: barrier 0x........</what>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_destroy</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  <first_observed_at>
+    <what>barrier</what>
+    <address>0x........</address>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  </first_observed_at>
+</error>
+
+
+destroy a barrier that was never initialised
+<error>
+  <unique>0x........</unique>
+  <tid>...</tid>
+  <kind>BarrierErr</kind>
+  <what>Destruction of barrier that is being waited upon: barrier 0x........</what>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>free</fn>
+      <dir>...</dir>
+      <file>vg_replace_malloc.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  <first_observed_at>
+    <what>barrier</what>
+    <address>0x........</address>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>pthread_barrier_init</fn>
+      <dir>...</dir>
+      <file>drd_pthread_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>bar_bad.c</file>
+      <line>...</line>
+    </frame>
+  </stack>
+  </first_observed_at>
+</error>
+
+
+<status>
+  <state>FINISHED</state>
+  <time>...</time>
+</status>
+
+<errorcounts>
+  <pair>
+    <count>...</count>
+    <unique>0x........</unique>
+  </pair>
+  <pair>
+    <count>...</count>
+    <unique>0x........</unique>
+  </pair>
+  <pair>
+    <count>...</count>
+    <unique>0x........</unique>
+  </pair>
+  <pair>
+    <count>...</count>
+    <unique>0x........</unique>
+  </pair>
+  <pair>
+    <count>...</count>
+    <unique>0x........</unique>
+  </pair>
+</errorcounts>
+
+<suppcounts>...</suppcounts>
+
+</valgrindoutput>
+
index 0b750467b78d1b30c0304a30ad6bf14dac86297b..d84ac01273162bf36450feebd9c078f39a3d53d7 100644 (file)
@@ -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]);
   }
 
index 9f7e6d622fbc55dcaf1098e818eca6f6e37ed3ab..e098dd37a5de4cceb24f96882c0c761098a42150 100644 (file)
@@ -8,6 +8,7 @@
 #include <fcntl.h>    /* O_RDONLY */
 #include <pthread.h>
 #include <unistd.h>   /* close() */
+#include "config.h"
 
 /* Happens with two threads also */
 #define THREAD_COUNT 256
@@ -32,7 +33,9 @@ int main()
   pthread_t threads[THREAD_COUNT];
 
   pthread_attr_init(&attr);
+#if !defined(VGO_freebsd)
   pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
+#endif
   for (i = 0; i < THREAD_COUNT; ++i) {
     r = pthread_create(&threads[i], &attr, thread, 0);
     if (r != 0) {
index 19c339b647dffab1dfaf3981e896234804df7641..cc7834d877a81ff877828ff619ade58ff8db59d3 100644 (file)
@@ -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
similarity index 92%
rename from drd/tests/filter_error_count
rename to drd/tests/filter_error_count.in
index 89dc2b40c77ac7187d8319b2a6c248aeb1839df4..782284d1c7967aeaa638ee81560eb4880904aed3 100755 (executable)
@@ -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'
similarity index 62%
rename from drd/tests/filter_error_summary
rename to drd/tests/filter_error_summary.in
index cdf703f2fd9f136b2b2e0bd185e94bb00d8354bb..76d7a6dade561431177636776dbccd3dc8b434e9 100755 (executable)
@@ -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'
similarity index 94%
rename from drd/tests/filter_stderr
rename to drd/tests/filter_stderr.in
index f5c56a3541e768ad877a639267c06024b9c07ae2..aec1d60f5d7414068ebdfd3f48aa590d1da4e850 100755 (executable)
@@ -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 (executable)
index b0e75a4..0000000
+++ /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 (executable)
index 0000000..095d44d
--- /dev/null
@@ -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 /"
similarity index 82%
rename from drd/tests/filter_thread_no
rename to drd/tests/filter_thread_no.in
index f70c7b6682efa3b0de5139f3e1d780adf8d74d8c..6fac735705699211a225b49f43ae6609148a00d4 100755 (executable)
@@ -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"
similarity index 55%
rename from drd/tests/filter_xml_and_thread_no
rename to drd/tests/filter_xml_and_thread_no.in
index a9f7ac1af573d7bbb821aa20ac55d4526a11b0ef..db64dd77429373208b82b9be6350533a5c1593f5 100755 (executable)
@@ -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'
index e0771243d9391d5f88cce558c70e10d6e80e523c..add1b33f0a931850f49c9ccc814c7c4cd2aeded8 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <pthread.h>
+#include "config.h"
 
 
 static pthread_t s_thread[1000];
@@ -23,7 +24,9 @@ static void* thread_func(void* p)
     // std::cout << "create " << thread_count << std::endl;
     s_arg[thread_count] = thread_count;
     pthread_attr_init(&attr);
+#if !defined(VGO_freebsd)
     pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
+#endif
     pthread_create(&s_thread[thread_count], &attr, thread_func,
                    &s_arg[thread_count]);
     pthread_attr_destroy(&attr);
@@ -47,7 +50,9 @@ int main(int argc, char** argv)
   thread_count--;
   // std::cout << "create " << thread_count << std::endl;
   pthread_attr_init(&attr);
+#if !defined(VGO_freebsd)
   pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
+#endif
   pthread_create(&s_thread[thread_count], &attr, thread_func,
                  &thread_count);
   pthread_attr_destroy(&attr);
old mode 100644 (file)
new mode 100755 (executable)
index efeb15b..eab8514
@@ -6,6 +6,10 @@
 #include <stdio.h>
 #include <stdint.h>
 
+#if defined(VGO_freebsd)
+#include <sys/types.h>
+#endif
+
 static void* thread_func(void* arg)
 {
   return 0;
@@ -22,7 +26,11 @@ int main(int argc, char** argv)
   pthread_detach(thread);
 
   /* Invoke pthread_detach() with an invalid thread ID. */
+#ifdef VGO_freebsd
+  pthread_detach((pthread_t)12345);
+#else
   pthread_detach((pthread_t)((uintptr_t)thread + 8));
+#endif
 
   fprintf(stderr, "Finished.\n");
 
diff --git a/drd/tests/pth_detached3.stderr.exp-freebsd b/drd/tests/pth_detached3.stderr.exp-freebsd
new file mode 100644 (file)
index 0000000..870287d
--- /dev/null
@@ -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)
index e82dee14db37c949fa64431f43bbe0b4d614cd7e..d5910d8ebb1ed54b378e92cdd86d70e915559516 100644 (file)
@@ -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.
 
index fe031397df2e489ea485bf1a28ad944da80aaf0e..f0d9ac286bfc6baf5d7a37beb947f729b52d2ee9 100644 (file)
@@ -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 (file)
index 0000000..28c7a6d
--- /dev/null
@@ -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)
index 1f091645387a685c2f8310c21b509665f3fbf104..d266bba9cb709634e4f8f8133b9dd704c615d3f1 100644 (file)
 #include <string>
 #include <sstream>
 #include <list>
+#if defined(__FreeBSD__)
+#include <mutex>
+#endif
 
 using namespace std;
 
+#if defined(__FreeBSD__)
+std::mutex g_mutex;
+
+// according to this
+// https://stackoverflow.com/questions/4057319/is-setlocale-thread-safe-function
+// setlocale is not thread safe, and indeed on FreeBSD
+// a load of errors are generated if this is not guarded
+void setlocale_wrapper()
+{
+   const std::lock_guard<std::mutex> lock(g_mutex);
+   setlocale(LC_ALL, "English");
+}
+
+#else
+
+void setlocale_wrapper()
+{
+   setlocale(LC_ALL, "English");
+}
+
+#endif
+
 class SubTest {
 public:
   SubTest() {
@@ -41,7 +66,7 @@ class Test {
 public:
   void setUp() {
     subTest = new SubTest();
-    setlocale(LC_ALL, "English");
+    setlocale_wrapper();
   }
   void tearDown() {
     delete subTest; }
old mode 100644 (file)
new mode 100755 (executable)
index 266c93f..63f9472
@@ -8,6 +8,9 @@
 #include <string>
 #include <cstring>
 #include <pthread.h>
+#if defined(__FreeBSD__)
+#include <stdio.h>
+#endif
 #include <stdlib.h>
 #include <unistd.h>
 
index ae69e0ddd91979e7346c2d27294c7ae51e11efac..2e41bac5030b3cfea5d7c2c4fa872d21827e537b 100644 (file)
    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 (file)
index 0000000..e7828fd
--- /dev/null
@@ -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 (file)
index 0000000..384fd5c
--- /dev/null
@@ -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)
index 277705a548f84f3676dd7a50a1539eb19ce6a954..9a6c0474f541f549deda876f7f13d878876c8fbb 100644 (file)
@@ -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)
index f16c1dfe91502438d2808a29b749d841fd541430..5edf4e5ffe6129b18111e5650aea9acc0b3a0bf4 100644 (file)
@@ -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 (file)
index 0000000..8fbfa87
--- /dev/null
@@ -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)
index 753b5893879e2f2f37f8e9c34df8811f01837bad..f2c8ad34cd79e18932e14e69b8c3c688807100f2 100644 (file)
@@ -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)
index 868f5f3c3b380f6c7dbd3209cade3f113b8112d9..acd7bc682f04ba7d501f33e7aadf57e23a3230d2 100644 (file)
@@ -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 (file)
index 0000000..0f4954b
--- /dev/null
@@ -0,0 +1,63 @@
+/* Test whether assigning names to threads works properly. */
+
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include "../../drd/drd.h"
+
+
+#define NUM_THREADS 10
+
+
+static pthread_barrier_t s_barrier;
+static pthread_mutex_t s_mutex;
+static pthread_cond_t  s_cond;
+static int s_counter;
+
+static void* thread_func(void* argp)
+{
+  const int thread_num = (ptrdiff_t)(argp);
+  pthread_mutex_t invalid_mutex;
+  char thread_name[32];
+
+  snprintf(thread_name, sizeof(thread_name),
+           "thread_func instance %d", thread_num + 1);
+  ANNOTATE_THREAD_NAME(thread_name);
+
+  pthread_barrier_wait(&s_barrier);
+
+  pthread_mutex_lock(&s_mutex);
+  while (s_counter != thread_num)
+    pthread_cond_wait(&s_cond, &s_mutex);
+  fprintf(stderr, "\n%s\n\n", thread_name);
+  pthread_mutex_unlock(&invalid_mutex);
+  s_counter++;
+  pthread_cond_broadcast(&s_cond);
+  pthread_mutex_unlock(&s_mutex);
+
+  return 0;
+}
+
+
+int main(int arg, char** argv)
+{
+  int i;
+  pthread_t tid[NUM_THREADS];
+
+  pthread_barrier_init(&s_barrier, NULL, NUM_THREADS);
+  pthread_mutex_init(&s_mutex, 0);
+  pthread_cond_init(&s_cond, 0);
+
+  for (i = 0; i < NUM_THREADS; i++)
+    pthread_create(&tid[i], 0, thread_func, (void*)(ptrdiff_t)i);
+
+  for (i = 0; i < NUM_THREADS; i++)
+    pthread_join(tid[i], 0);
+
+  pthread_cond_destroy(&s_cond);
+  pthread_mutex_destroy(&s_mutex);
+
+  return 0;
+}
diff --git a/drd/tests/thread_name_freebsd.stderr.exp b/drd/tests/thread_name_freebsd.stderr.exp
new file mode 100644 (file)
index 0000000..a96e14a
--- /dev/null
@@ -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 (file)
index 0000000..e6317ac
--- /dev/null
@@ -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
index c6cd1cafb0a49e928f806a038077a3f7f17ede7b..4c8545e38be4d722b3d1d80fdebc7b14f02a8781 100644 (file)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index ad1af19..cf7f76d
@@ -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 \
index 0882b03a16fd9a4887c8ef1de043daaddea5c11a..22f70cdfafbc0b1eea02f28188df2f66fe64089e 100644 (file)
@@ -8,6 +8,7 @@
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+#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.
index f76663fbaea66e658f3444d21c6abaa03007ecd5..931d1973140d61ed4fc89f499d6f2a3ac45e14d0 100644 (file)
@@ -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 (file)
index 0000000..838e3a2
--- /dev/null
@@ -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 (file)
index 0000000..f7eadaf
--- /dev/null
@@ -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;}
similarity index 84%
rename from helgrind/tests/filter_stderr
rename to helgrind/tests/filter_stderr.in
index 6b85663bc00c6a59ccf725b3e6e05ccded99f612..9953b6527f84786892ab57d0edf39da8fc3bb1a1 100755 (executable)
@@ -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 (executable)
index 0000000..7c89e04
--- /dev/null
@@ -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 (file)
index 0000000..c04588e
--- /dev/null
@@ -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 (file)
index 0000000..75af898
--- /dev/null
@@ -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 (file)
index 0000000..6ffa3c2
--- /dev/null
@@ -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 (file)
index 0000000..65a79a7
--- /dev/null
@@ -0,0 +1,251 @@
+<?xml version="1.0"?>
+
+<valgrindoutput>
+
+<protocolversion>4</protocolversion>
+<protocoltool>helgrind</protocoltool>
+
+<preamble>
+  <line>Helgrind, a thread error detector</line>
+  <line>Copyright (C) XXXX-YYYY, and GNU GPL'd, by OpenWorks LLP et al.</line>
+  <line>Using Valgrind-X.Y.X and LibVEX; rerun with -h for copyright info</line>
+  <line>Command: ./tc06_two_races</line>
+</preamble>
+
+<pid>...</pid>
+<ppid>...</ppid>
+<tool>helgrind</tool>
+
+<args>
+  <vargv>
+    <exe>...</exe>
+    <arg>--command-line-only=yes</arg>
+    <arg>--memcheck:leak-check=no</arg>
+    <arg>--tool=helgrind</arg>
+    <arg>--read-var-info=yes</arg>
+    <arg>--xml=yes</arg>
+    <arg>--xml-fd=2</arg>
+    <arg>--log-file=/dev/null</arg>
+  </vargv>
+  <argv>
+    <exe>...</exe>
+  </argv>
+</args>
+
+<status>
+  <state>RUNNING</state>
+  <time>...</time>
+</status>
+
+<announcethread>
+  <hthreadid>1</hthreadid>
+  <isrootthread></isrootthread>
+</announcethread>
+
+<announcethread>
+  <hthreadid>2</hthreadid>
+  <stack>
+    <frame>...</frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>26</line>
+    </frame>
+  </stack>
+</announcethread>
+
+<error>
+  <unique>...</unique>
+  <tid>...</tid>
+  <kind>Race</kind>
+  <xwhat>
+    <text>Possible data race during read of size 4 at 0x........ by thread #x</text>
+    <hthreadid>1</hthreadid>
+  </xwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>31</line>
+    </frame>
+  </stack>
+  <xauxwhat>
+    <text>This conflicts with a previous write of size 4 by thread #x</text>
+    <hthreadid>2</hthreadid>
+  </xauxwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>child_fn</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>14</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>mythread_wrapper</fn>
+      <dir>...</dir>
+      <file>hg_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>...</frame>
+  </stack>
+  <auxwhat>Location 0x........ is 0 bytes inside global var "unprot1"</auxwhat>
+  <xauxwhat><text>declared at tc06_two_races.c:9</text> <file>tc06_two_races.c</file> <line>9</line> </xauxwhat>
+</error>
+
+<error>
+  <unique>...</unique>
+  <tid>...</tid>
+  <kind>Race</kind>
+  <xwhat>
+    <text>Possible data race during write of size 4 at 0x........ by thread #x</text>
+    <hthreadid>1</hthreadid>
+  </xwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>31</line>
+    </frame>
+  </stack>
+  <xauxwhat>
+    <text>This conflicts with a previous write of size 4 by thread #x</text>
+    <hthreadid>2</hthreadid>
+  </xauxwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>child_fn</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>14</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>mythread_wrapper</fn>
+      <dir>...</dir>
+      <file>hg_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>...</frame>
+  </stack>
+  <auxwhat>Location 0x........ is 0 bytes inside global var "unprot1"</auxwhat>
+  <xauxwhat><text>declared at tc06_two_races.c:9</text> <file>tc06_two_races.c</file> <line>9</line> </xauxwhat>
+</error>
+
+<error>
+  <unique>...</unique>
+  <tid>...</tid>
+  <kind>Race</kind>
+  <xwhat>
+    <text>Possible data race during read of size 4 at 0x........ by thread #x</text>
+    <hthreadid>1</hthreadid>
+  </xwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>35</line>
+    </frame>
+  </stack>
+  <xauxwhat>
+    <text>This conflicts with a previous write of size 4 by thread #x</text>
+    <hthreadid>2</hthreadid>
+  </xauxwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>child_fn</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>18</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>mythread_wrapper</fn>
+      <dir>...</dir>
+      <file>hg_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>...</frame>
+  </stack>
+  <auxwhat>Location 0x........ is 0 bytes inside global var "unprot2"</auxwhat>
+  <xauxwhat><text>declared at tc06_two_races.c:9</text> <file>tc06_two_races.c</file> <line>9</line> </xauxwhat>
+</error>
+
+<error>
+  <unique>...</unique>
+  <tid>...</tid>
+  <kind>Race</kind>
+  <xwhat>
+    <text>Possible data race during write of size 4 at 0x........ by thread #x</text>
+    <hthreadid>1</hthreadid>
+  </xwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>main</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>35</line>
+    </frame>
+  </stack>
+  <xauxwhat>
+    <text>This conflicts with a previous write of size 4 by thread #x</text>
+    <hthreadid>2</hthreadid>
+  </xauxwhat>
+  <stack>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>child_fn</fn>
+      <dir>...</dir>
+      <file>tc06_two_races.c</file>
+      <line>18</line>
+    </frame>
+    <frame>
+      <ip>0x........</ip>
+      <obj>...</obj>
+      <fn>mythread_wrapper</fn>
+      <dir>...</dir>
+      <file>hg_intercepts.c</file>
+      <line>...</line>
+    </frame>
+    <frame>...</frame>
+  </stack>
+  <auxwhat>Location 0x........ is 0 bytes inside global var "unprot2"</auxwhat>
+  <xauxwhat><text>declared at tc06_two_races.c:9</text> <file>tc06_two_races.c</file> <line>9</line> </xauxwhat>
+</error>
+
+
+<status>
+  <state>FINISHED</state>
+  <time>...</time>
+</status>
+
+<errorcounts>...</errorcounts>
+
+<suppcounts>...</suppcounts>
+
+</valgrindoutput>
+
index 3972b512eef5070caba7fa7224054f9b38215f00..54297dee6847feca1aa62d1dcfe2b9a3fdc51663 100644 (file)
@@ -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
 #  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" )
index e84ecec4a1f0e36bc33b7a334d05fa9e0afa0cd1..c3a2ec79465086ba2c619657c3ac95e732a4db76 100644 (file)
@@ -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
 #  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" )
index 238ce9bf6518fbb968c850baa4fdc4cac664b568..9e4a8801d77a7a79d53f56ac00ae4a6fcda000cd 100644 (file)
@@ -5,6 +5,7 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
+#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. */
index a18450b9a89ae5836ba5a724b38d9d81853566ff..1eeac5f4bde0f0af8754ad75bdb8c5ee4f806bd3 100644 (file)
@@ -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 (file)
index 0000000..1053cbe
--- /dev/null
@@ -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)
index 8baa420c8715837a3d79023100fa3d11d2128a51..c670b266cc349ce712b28fdee8197f0b1f054f3f 100644 (file)
@@ -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)
 
 ----------------------------------------------------------------
 
index 15167e87e8e44e4cdcf7c8d4e653c821c1874f78..f6ff1c9846bde88141f8afde2e3ad7ca92a31226 100644 (file)
@@ -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
 #  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" \
index a84428e018e5fbd56b841f11dbfb259466a98ebe..35702ebb09f0c2a7615b22829069263661e7f1d1 100644 (file)
@@ -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 (file)
index 0000000..69ffcf8
--- /dev/null
@@ -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)
index 88a1fe5bb6d54d6d10260d1d2cae21e06b414c27..36412a07e2065c0a968ffa9fb67ef0dec08e6cf6 100644 (file)
@@ -4,6 +4,9 @@
 #include <pthread.h>
 #include <semaphore.h>
 #include <unistd.h>
+#if defined(VGO_freebsd)
+# include <sys/fcntl.h>
+#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 (file)
index 0000000..6eacf90
--- /dev/null
@@ -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)
index c110000791a2da28c65d215108be7e73bcd7d7f6..ae97bde8d3bfeccfc584edc79a0b6e65f0717951 100644 (file)
@@ -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. */
index 0ee9c143d93f7532ba4ec1669a6305f6023d8f52..cde1b21751394bb6988ed103124080331ddc3269 100644 (file)
@@ -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
index 2471541bab5d178f54f9ed74f5e017c6a599d403..2e6190a727c2c7f8cbb98377f3d633a58b211a3a 100644 (file)
@@ -1,2 +1,3 @@
 prereq: test -e tc22_exit_w_lock
 prog: tc22_exit_w_lock
+cleanup: rm -f vgcore.*
index 6ea5ad90be08ace1a44859d005f53901d68fba91..f2ccf3517fd45ad3a68d6a1eec337694d73a4a20 100644 (file)
@@ -7,6 +7,9 @@
 #include <semaphore.h>
 #include <stdio.h>
 #include <stdlib.h>
+#if defined(VGO_freebsd)
+#include <sys/fcntl.h>
+#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) {
index a6e6df3f5c6654b70711d23318cd910944fc6aff..e1611a5d8f85ffc4960c064bceb925f9ed2e9aef 100644 (file)
@@ -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 (file)
index 0000000..1eee38a
--- /dev/null
@@ -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)
index bcd467ccbdf483ca7fba379cc1b5d69505c5322e..541fa7ddb8816a1a77aa98b00d046aa656c64b71 100644 (file)
@@ -9,6 +9,9 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
+#if defined(VGO_freebsd)
+# include <sys/fcntl.h>
+#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) {
index 3e0ae4cbc68fa8b4715159b703b0e0c1a9fcc733..c51e26ce26bd6070801133f3605b6e5d4b205a69 100755 (executable)
@@ -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"
index d3c5a69d04c99cc4919a9ec6996b02da72018e50..7e47bf0ce46b49341e9b583fc0d753b396eecb16 100644 (file)
@@ -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_*