|
From: Nicholas N. <nj...@ca...> - 2004-01-09 16:15:38
|
CVS commit by nethercote:
Remove address from output, which varies from machine to machine and causes
failure.
M +2 -2 as_shm.c 1.3 [POSSIBLY UNSAFE: printf]
M +1 -1 as_shm.stdout.exp 1.2
--- valgrind/corecheck/tests/as_shm.c #1.2:1.3
@@ -19,5 +19,5 @@ int main()
perror("shmat @ 0");
else
- printf("shmat 0: addr=%p\n", addr);
+ printf("shmat 0: addr=...\n");
addr = shmat(shmid, top, 0);
@@ -26,5 +26,5 @@ int main()
perror("shmat @ top");
else
- printf("shmat 2: addr=%p\n", addr);
+ printf("shmat 2: addr=...\n");
shmctl(shmid, IPC_RMID, NULL);
--- valgrind/corecheck/tests/as_shm.stdout.exp #1.1:1.2
@@ -1 +1 @@
-shmat 0: addr=0x81156000
+shmat 0: addr=...
|
|
From: Nicholas N. <nj...@ca...> - 2004-10-26 16:30:05
|
CVS commit by nethercote:
Tweak as_mmap for the possibility of a PIE-supporting system with a 4GB user
space.
A filter_as_mmap 1.1
M +1 -1 Makefile.am 1.25
M +14 -5 as_mmap.c 1.2 [POSSIBLY UNSAFE: printf]
M +11 -6 as_mmap.stderr.exp 1.2
M +5 -0 as_mmap.stderr.exp2 1.2
M +1 -0 as_mmap.vgtest 1.2
--- valgrind/corecheck/tests/Makefile.am #1.24:1.25
@@ -5,5 +5,5 @@
##---------------------------------------------------------------------------
-noinst_SCRIPTS = filter_stderr filter_fdleak
+noinst_SCRIPTS = filter_stderr filter_as_mmap filter_fdleak
EXTRA_DIST = $(noinst_SCRIPTS) \
--- valgrind/corecheck/tests/as_mmap.c #1.1:1.2
@@ -7,19 +7,28 @@ int main()
char *top = (char *)(((unsigned long)&local + 0x0fffffff) & ~0x0fffffff);
+ fprintf(stderr, "1\n");
if (mmap((void *)0x00000000, 0x10000, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED)
- perror("mmap @ 0x00000000");
+ fprintf(stderr, "mmap @ 0x00000000\n");
+
+ fprintf(stderr, "2\n");
if (mmap((void *)0x00010000, 0x10000, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED)
- perror("mmap @ 0x00010000");
+ fprintf(stderr, "mmap @ 0x00010000\n");
+
+ fprintf(stderr, "3\n");
if (mmap((void *)0x50000000, 0x10000, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED)
- perror("mmap @ 0x50000000");
+ fprintf(stderr, "mmap @ 0x50000000\n");
+
+ fprintf(stderr, "4\n");
if (mmap(top, 0x10000, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED)
- perror("mmap @ top");
+ fprintf(stderr, "mmap @ top\n");
+
+ fprintf(stderr, "5\n");
if (mmap(top+0x08000000, 0x10000, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED)
- perror("mmap @ top+.5G");
+ fprintf(stderr, "mmap @ top+.5G\n");
return 0;
--- valgrind/corecheck/tests/as_mmap.stderr.exp #1.1:1.2
@@ -1,9 +1,14 @@
-Warning: client syscall mmap2 tried to modify addresses 0x0-0x10000
-mmap @ 0x00000000: Cannot allocate memory
-Warning: client syscall mmap2 tried to modify addresses 0xB0000000-0xB0010000
-mmap @ top: Cannot allocate memory
-Warning: client syscall mmap2 tried to modify addresses 0xB8000000-0xB8010000
-mmap @ top+.5G: Cannot allocate memory
+1
+Warning: client syscall mmap2 tried to modify addresses 0x........-0x........
+mmap @ 0x........
+2
+3
+4
+Warning: client syscall mmap2 tried to modify addresses 0x........-0x........
+mmap @ top
+5
+Warning: client syscall mmap2 tried to modify addresses 0x........-0x........
+mmap @ top+.5G
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--- valgrind/corecheck/tests/as_mmap.stderr.exp2 #1.1:1.2
@@ -1,7 +1,12 @@
+1
Warning: client syscall mmap tried to modify addresses 0x0-0x10000
mmap @ 0x00000000: Cannot allocate memory
+2
+3
+4
Warning: client syscall mmap tried to modify addresses 0xB0000000-0xB0010000
mmap @ top: Cannot allocate memory
+5
Warning: client syscall mmap tried to modify addresses 0xB8000000-0xB8010000
mmap @ top+.5G: Cannot allocate memory
--- valgrind/corecheck/tests/as_mmap.vgtest #1.1:1.2
@@ -1 +1,2 @@
prog: as_mmap
+stderr_filter: filter_as_mmap
|
|
From: Tom H. <th...@cy...> - 2004-10-28 13:39:55
|
CVS commit by thughes:
Remove the thread numbers from the messages output by pth_once so that
the order the threads run in doesn't affect the output.
M +1 -2 pth_once.c 1.4 [POSSIBLY UNSAFE: printf]
M +10 -10 pth_once.stdout.exp 1.4
--- valgrind/corecheck/tests/pth_once.c #1.3:1.4
@@ -40,5 +40,4 @@ void welcome(void)
void *identify_yourself(void *arg)
{
- int *pid=(int *)arg;
int rtn;
@@ -48,5 +47,5 @@ void *identify_yourself(void *arg)
pthread_exit((void *)NULL);
}
- printf("identify_yourself: Hi, I'm thread # %d\n",*pid);
+ printf("identify_yourself: Hi, I'm a thread\n");
return(NULL);
}
--- valgrind/corecheck/tests/pth_once.stdout.exp #1.3:1.4
@@ -1,12 +1,12 @@
welcome: Welcome
-identify_yourself: Hi, I'm thread # 0
-identify_yourself: Hi, I'm thread # 1
-identify_yourself: Hi, I'm thread # 2
-identify_yourself: Hi, I'm thread # 3
-identify_yourself: Hi, I'm thread # 4
-identify_yourself: Hi, I'm thread # 5
-identify_yourself: Hi, I'm thread # 6
-identify_yourself: Hi, I'm thread # 7
-identify_yourself: Hi, I'm thread # 8
-identify_yourself: Hi, I'm thread # 9
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
+identify_yourself: Hi, I'm a thread
main: Goodbye
|
|
From: Nicholas N. <nj...@ca...> - 2004-11-09 14:58:14
|
CVS commit by nethercote:
Improve pth_cvsimple test in two ways:
1. Make the output deterministic; different thread interleaving from expected
was causing failures for me.
2. Make it actually use the condition variable -- the condvar stupidly wasn't
actually being used in the expected case, because the other threads finished
all their work before pthread_cond_wait() even got called, and this prevented
the condition guarding pthread_cond_wait() from succeeding.
M +22 -15 pth_cvsimple.c 1.3 [POSSIBLY UNSAFE: printf]
M +22 -22 pth_cvsimple.stdout.exp 1.3
--- valgrind/corecheck/tests/pth_cvsimple.c #1.2:1.3
@@ -10,5 +10,5 @@
* cvsimple.c
*
- * Demonstrates pthread cancellation.
+ * Demonstrates pthread condvars.
*
*/
@@ -21,4 +21,5 @@
#define COUNT_THRES 12
+int condvar_was_hit = 0;
int count = 0;
int thread_ids[3] = {0,1,2};
@@ -26,16 +27,14 @@ pthread_mutex_t count_lock=PTHREAD_MUTEX
pthread_cond_t count_hit_threshold=PTHREAD_COND_INITIALIZER;
-void *inc_count(void *idp)
+void *inc_count(void *null)
{
int i=0;
- int *my_id = idp;
for (i=0; i<TCOUNT; i++) {
pthread_mutex_lock(&count_lock);
count++;
- printf("inc_counter(): thread %d, count = %d, unlocking mutex\n",
- *my_id, count);
+ printf("inc_counter(): count = %d, unlocking mutex\n", count);
if (count == COUNT_THRES) {
- printf("inc_count(): Thread %d, count %d\n", *my_id, count);
+ printf("hit threshold!\n");
pthread_cond_signal(&count_hit_threshold);
}
@@ -46,15 +45,11 @@ void *inc_count(void *idp)
}
-void *watch_count(void *idp)
+void *watch_count(void *null)
{
- int *my_id = idp;
-
- printf("watch_count(): thread %d\n", *my_id);
- fflush(stdout);
pthread_mutex_lock(&count_lock);
while (count < COUNT_THRES) {
pthread_cond_wait(&count_hit_threshold, &count_lock);
- printf("watch_count(): thread %d, count %d\n", *my_id, count);
+ condvar_was_hit = 1;
}
@@ -70,7 +65,7 @@ main(void)
pthread_t threads[3];
- pthread_create(&threads[0], NULL, inc_count, (void *)&thread_ids[0]);
- pthread_create(&threads[1], NULL, inc_count, (void *)&thread_ids[1]);
- pthread_create(&threads[2], NULL, watch_count, (void *)&thread_ids[2]);
+ pthread_create(&threads[0], NULL, watch_count, NULL);
+ pthread_create(&threads[1], NULL, inc_count, NULL);
+ pthread_create(&threads[2], NULL, inc_count, NULL);
for (i = 0; i < NUM_THREADS; i++) {
@@ -78,4 +73,16 @@ main(void)
}
+ // Nb: it's not certain that we'll hit here. It's possible that the two
+ // inc_count threads could fully run before watch_count begins, and so
+ // pthread_cond_wait() is never called. Or, we could get a spurious
+ // wake-up in watch_count(). Nonetheless, it's very likely that things
+ // will work out as expected, since we're starting watch_count() first.
+ if (condvar_was_hit == 1)
+ printf("condvar was hit!\n");
+ else if (condvar_was_hit > 1)
+ printf("condvar was multi-hit...\n");
+ else
+ printf("condvar was missed...\n");
+
return 0;
}
--- valgrind/corecheck/tests/pth_cvsimple.stdout.exp #1.2:1.3
@@ -1,22 +1,22 @@
-inc_counter(): thread 0, count = 1, unlocking mutex
-inc_counter(): thread 0, count = 2, unlocking mutex
-inc_counter(): thread 0, count = 3, unlocking mutex
-inc_counter(): thread 0, count = 4, unlocking mutex
-inc_counter(): thread 0, count = 5, unlocking mutex
-inc_counter(): thread 0, count = 6, unlocking mutex
-inc_counter(): thread 0, count = 7, unlocking mutex
-inc_counter(): thread 0, count = 8, unlocking mutex
-inc_counter(): thread 0, count = 9, unlocking mutex
-inc_counter(): thread 0, count = 10, unlocking mutex
-inc_counter(): thread 1, count = 11, unlocking mutex
-inc_counter(): thread 1, count = 12, unlocking mutex
-inc_count(): Thread 1, count 12
-inc_counter(): thread 1, count = 13, unlocking mutex
-inc_counter(): thread 1, count = 14, unlocking mutex
-inc_counter(): thread 1, count = 15, unlocking mutex
-inc_counter(): thread 1, count = 16, unlocking mutex
-inc_counter(): thread 1, count = 17, unlocking mutex
-inc_counter(): thread 1, count = 18, unlocking mutex
-inc_counter(): thread 1, count = 19, unlocking mutex
-inc_counter(): thread 1, count = 20, unlocking mutex
-watch_count(): thread 2
+inc_counter(): count = 1, unlocking mutex
+inc_counter(): count = 2, unlocking mutex
+inc_counter(): count = 3, unlocking mutex
+inc_counter(): count = 4, unlocking mutex
+inc_counter(): count = 5, unlocking mutex
+inc_counter(): count = 6, unlocking mutex
+inc_counter(): count = 7, unlocking mutex
+inc_counter(): count = 8, unlocking mutex
+inc_counter(): count = 9, unlocking mutex
+inc_counter(): count = 10, unlocking mutex
+inc_counter(): count = 11, unlocking mutex
+inc_counter(): count = 12, unlocking mutex
+hit threshold!
+inc_counter(): count = 13, unlocking mutex
+inc_counter(): count = 14, unlocking mutex
+inc_counter(): count = 15, unlocking mutex
+inc_counter(): count = 16, unlocking mutex
+inc_counter(): count = 17, unlocking mutex
+inc_counter(): count = 18, unlocking mutex
+inc_counter(): count = 19, unlocking mutex
+inc_counter(): count = 20, unlocking mutex
+condvar was hit!
|