|
From: <sv...@va...> - 2007-10-15 21:58:54
|
Author: sewardj
Date: 2007-10-15 22:58:54 +0100 (Mon, 15 Oct 2007)
New Revision: 6998
Log:
Add a regression test demonstrating byte-level lockset tracking.
Added:
branches/THRCHECK/thrcheck/tests/tc16_byterace.c
branches/THRCHECK/thrcheck/tests/tc16_byterace.stderr.exp
branches/THRCHECK/thrcheck/tests/tc16_byterace.stdout.exp
branches/THRCHECK/thrcheck/tests/tc16_byterace.vgtest
Modified:
branches/THRCHECK/thrcheck/tests/Makefile.am
Modified: branches/THRCHECK/thrcheck/tests/Makefile.am
===================================================================
--- branches/THRCHECK/thrcheck/tests/Makefile.am 2007-10-15 21:56:19 UTC (rev 6997)
+++ branches/THRCHECK/thrcheck/tests/Makefile.am 2007-10-15 21:58:54 UTC (rev 6998)
@@ -40,7 +40,9 @@
tc14_laog_dinphils.vgtest tc14_laog_dinphils.stderr.exp \
tc14_laog_dinphils.stdout.exp \
tc15_laog_lockdel.vgtest tc15_laog_lockdel.stderr.exp \
- tc15_laog_lockdel.stdout.exp
+ tc15_laog_lockdel.stdout.exp \
+ tc16_byterace.vgtest tc16_byterace.stderr.exp \
+ tc16_byterace.stdout.exp
check_PROGRAMS = \
hg01_all_ok \
@@ -63,7 +65,8 @@
tc12_rwl_trivial \
tc13_laog1 \
tc14_laog_dinphils \
- tc15_laog_lockdel
+ tc15_laog_lockdel \
+ tc16_byterace
# is this necessary?
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g $(AM_FLAG_M3264_PRI)
Added: branches/THRCHECK/thrcheck/tests/tc16_byterace.c
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc16_byterace.c (rev 0)
+++ branches/THRCHECK/thrcheck/tests/tc16_byterace.c 2007-10-15 21:58:54 UTC (rev 6998)
@@ -0,0 +1,42 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Simple demonstration of lockset tracking at byte granularity. */
+
+char bytes[10];
+
+void* child_fn ( void* arg )
+{
+ int i;
+ for (i = 0; i < 5; i++)
+ bytes[2*i + 0] ++;
+ return NULL;
+}
+
+int main ( void )
+{
+ int i;
+ pthread_t child;
+
+ if (pthread_create(&child, NULL, child_fn, NULL)) {
+ perror("pthread_create");
+ exit(1);
+ }
+
+ /* Unprotected relative to child, but harmless, since different
+ bytes accessed */
+ for (i = 0; i < 5; i++)
+ bytes[2*i + 1] ++;
+
+ /* Unprotected relative to child, but harmful; same bytes */
+ for (i = 0; i < 3; i++)
+ bytes[3*i + 1] ++;
+
+ if (pthread_join(child, NULL)) {
+ perror("pthread join");
+ exit(1);
+ }
+
+ return 0;
+}
Added: branches/THRCHECK/thrcheck/tests/tc16_byterace.stderr.exp
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc16_byterace.stderr.exp (rev 0)
+++ branches/THRCHECK/thrcheck/tests/tc16_byterace.stderr.exp 2007-10-15 21:58:54 UTC (rev 6998)
@@ -0,0 +1,18 @@
+
+Thread #1 is the program's root thread
+
+Thread #2 was created
+ at 0x........: clone (in /...libc...)
+ by 0x........: ...
+ by 0x........: pthread_create@@GLIBC_2.2.5 (in /lib/libpthread...)
+ by 0x........: pthread_create@* (tc_intercepts.c:...)
+ by 0x........: main (tc16_byterace.c:22)
+
+Possible data race during write to 0x........
+ at 0x........: main (tc16_byterace.c:34)
+ Old state: shared-readonly by threads #1, #2
+ New state: shared-modified by threads #1, #2
+ Reason: this thread, #1, holds no consistent locks
+ Location 0x........ has never been protected by any lock
+
+ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Added: branches/THRCHECK/thrcheck/tests/tc16_byterace.stdout.exp
===================================================================
Added: branches/THRCHECK/thrcheck/tests/tc16_byterace.vgtest
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc16_byterace.vgtest (rev 0)
+++ branches/THRCHECK/thrcheck/tests/tc16_byterace.vgtest 2007-10-15 21:58:54 UTC (rev 6998)
@@ -0,0 +1 @@
+prog: tc16_byterace
|