From: no author Date: Wed, 13 Oct 2004 09:58:53 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f37ace60bc3c5c93c2a847c8af74fecae25d15b9;p=thirdparty%2Fvalgrind.git This commit was manufactured by cvs2svn to create branch 'VALGRIND_2_2_0_BRANCH'. git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_2_2_0_BRANCH@2744 --- diff --git a/memcheck/tests/badjump2.c b/memcheck/tests/badjump2.c new file mode 100644 index 0000000000..361966b6c1 --- /dev/null +++ b/memcheck/tests/badjump2.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include + +// Regression test for bug 91162: if a client had a SEGV signal handler, +// and jumped to a bogus address, Valgrind would abort. With the fix, +// the following test runs to completion correctly. + +static jmp_buf myjmpbuf; + +static +void SIGSEGV_handler(int signum) +{ + __builtin_longjmp(myjmpbuf, 1); +} + +int main(void) +{ + struct sigaction sigsegv_new, sigsegv_saved; + int res; + + /* Install own SIGSEGV handler */ + sigsegv_new.sa_handler = SIGSEGV_handler; + sigsegv_new.sa_flags = 0; + sigsegv_new.sa_restorer = NULL; + res = sigemptyset( &sigsegv_new.sa_mask ); + assert(res == 0); + + res = sigaction( SIGSEGV, &sigsegv_new, &sigsegv_saved ); + assert(res == 0); + + if (__builtin_setjmp(myjmpbuf) == 0) { + // Jump to zero; will cause seg fault + void (*fn)(void) = 0; + fn(); + fprintf(stderr, "Got here??\n"); + } else { + fprintf(stderr, "Signal caught, as expected\n"); + } + + return 0; +} + diff --git a/memcheck/tests/badjump2.stderr.exp b/memcheck/tests/badjump2.stderr.exp new file mode 100644 index 0000000000..04db2d9b78 --- /dev/null +++ b/memcheck/tests/badjump2.stderr.exp @@ -0,0 +1,6 @@ +Jump to the invalid address stated on the next line + at 0x........: ??? + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +Signal caught, as expected diff --git a/memcheck/tests/badjump2.vgtest b/memcheck/tests/badjump2.vgtest new file mode 100644 index 0000000000..4256086d5c --- /dev/null +++ b/memcheck/tests/badjump2.vgtest @@ -0,0 +1,2 @@ +prog: badjump2 +vgopts: -q