From 979dc8596b3e733c6cdbc019373fd9c1ac60d56e Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Sun, 21 Oct 2012 18:46:09 +0000 Subject: [PATCH] Introduce a test to reproduce bug 123837 (semctl GETVAL false positive) The test succeeds on amd64, but fails on x86, with the following diff: +Syscall param semctl(arg) points to uninitialised byte(s) + at 0x........: semctl@@GLIBC_2.2 (semctl.c:109) + by 0x........: main (sem.c:36) + Address 0x........ is on thread 1's stack + +Syscall param semctl(arg) points to uninitialised byte(s) + at 0x........: semctl@@GLIBC_2.2 (semctl.c:109) + by 0x........: main (sem.c:43) + Address 0x........ is on thread 1's stack + git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13073 --- memcheck/tests/Makefile.am | 1 + memcheck/tests/sem.stderr.exp | 10 ++++++++++ memcheck/tests/sem.vgtest | 1 + none/tests/sem.c | 15 +++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 memcheck/tests/sem.stderr.exp create mode 100644 memcheck/tests/sem.vgtest diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 68cf9c9b2..cf1d5cc12 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -180,6 +180,7 @@ EXTRA_DIST = \ realloc2.stderr.exp realloc2.vgtest \ realloc3.stderr.exp realloc3.vgtest \ sbfragment.stdout.exp sbfragment.stderr.exp sbfragment.vgtest \ + sem.stderr.exp sem.vgtest \ sh-mem.stderr.exp sh-mem.vgtest \ sh-mem-random.stderr.exp sh-mem-random.stdout.exp64 \ sh-mem-random.stdout.exp sh-mem-random.vgtest \ diff --git a/memcheck/tests/sem.stderr.exp b/memcheck/tests/sem.stderr.exp new file mode 100644 index 000000000..c22dd7f4c --- /dev/null +++ b/memcheck/tests/sem.stderr.exp @@ -0,0 +1,10 @@ + + +HEAP SUMMARY: + in use at exit: 0 bytes in 0 blocks + total heap usage: 0 allocs, 0 frees, 0 bytes allocated + +For a detailed leak analysis, rerun with: --leak-check=full + +For counts of detected and suppressed errors, rerun with: -v +ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/sem.vgtest b/memcheck/tests/sem.vgtest new file mode 100644 index 000000000..876f00211 --- /dev/null +++ b/memcheck/tests/sem.vgtest @@ -0,0 +1 @@ +prog: ../../none/tests/sem diff --git a/none/tests/sem.c b/none/tests/sem.c index ef3c09108..27db0713c 100644 --- a/none/tests/sem.c +++ b/none/tests/sem.c @@ -7,6 +7,7 @@ #include #include #include +#include int main(int argc, char **argv) { int semid; @@ -32,6 +33,20 @@ int main(int argc, char **argv) exit(1); } + if (semctl(semid, 0, GETVAL) != 1) + { + perror("semctl GETVAL"); + semctl(semid, 0, IPC_RMID); + exit(1); + } + + if (semctl(semid, 0, GETPID) != getpid()) + { + perror("semctl GETPID"); + semctl(semid, 0, IPC_RMID); + exit(1); + } + /* The next call to semtimedop causes the program to hang on ppc32-linux (Yellow Dog 4.0). I don't know why. Hence the extended ifdef. */