|
From: <sv...@va...> - 2015-08-19 13:26:35
|
Author: mjw
Date: Wed Aug 19 14:26:28 2015
New Revision: 15570
Log:
Also install sigsegv handler in safe-pthread tests wrapper.
In case we do recognize the xend, but detect it is invalid
(used outside a transaction) we generate a segsegv instead
of a sigill. Handle that in the same way in the test case.
Modified:
trunk/drd/tests/tc12_rwl_trivial.stderr.exp
trunk/helgrind/tests/safe-pthread.h
Modified: trunk/drd/tests/tc12_rwl_trivial.stderr.exp
==============================================================================
--- trunk/drd/tests/tc12_rwl_trivial.stderr.exp (original)
+++ trunk/drd/tests/tc12_rwl_trivial.stderr.exp Wed Aug 19 14:26:28 2015
@@ -1,7 +1,7 @@
Reader-writer lock not locked by calling thread: rwlock 0x.........
at 0x........: pthread_rwlock_unlock (drd_pthread_intercepts.c:?)
- by 0x........: safe_pthread_rwlock_unlock (safe-pthread.h:41)
+ by 0x........: safe_pthread_rwlock_unlock (safe-pthread.h:58)
by 0x........: main (tc12_rwl_trivial.c:29)
rwlock 0x........ was first observed at:
at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?)
Modified: trunk/helgrind/tests/safe-pthread.h
==============================================================================
--- trunk/helgrind/tests/safe-pthread.h (original)
+++ trunk/helgrind/tests/safe-pthread.h Wed Aug 19 14:26:28 2015
@@ -19,6 +19,16 @@
}
/*
+ * Same as above, but in case we do recognize the xend,
+ * but detect it is invalid (used outside a transaction)
+ * and generate a segv. Unfortunately then si_addr is,
+ * just zero, so we cannot add an assert/sanity check.
+ */
+static void segv_handler( int signum, siginfo_t *siginfo, void *sigcontext ) {
+ longjmp( env, EPERM );
+}
+
+/*
* Wrapper for pthread_rwlock_unlock which may execute xend
* unconditionally when used on a lock that is not locked.
*
@@ -26,16 +36,23 @@
* glibc normally does - error reporting is optional.
*/
static int safe_pthread_rwlock_unlock( pthread_rwlock_t *rwlock ) {
- struct sigaction sa;
- struct sigaction oldsa;
+ struct sigaction sa_ill, sa_segv;
+ struct sigaction oldsa_ill, oldsa_segv;
int r;
- sa.sa_handler = NULL;
- sa.sa_sigaction = sigill_handler;
- sigemptyset( &sa.sa_mask );
- sa.sa_flags = SA_SIGINFO;
+ sa_ill.sa_handler = NULL;
+ sa_ill.sa_sigaction = sigill_handler;
+ sigemptyset( &sa_ill.sa_mask );
+ sa_ill.sa_flags = SA_SIGINFO;
- sigaction( SIGILL, &sa, &oldsa );
+ sigaction( SIGILL, &sa_ill, &oldsa_ill );
+
+ sa_segv.sa_handler = NULL;
+ sa_segv.sa_sigaction = segv_handler;
+ sigemptyset( &sa_segv.sa_mask );
+ sa_segv.sa_flags = SA_SIGINFO;
+
+ sigaction( SIGSEGV, &sa_segv, &oldsa_segv );
if ( ( r = setjmp( env ) ) == 0 ) {
r = pthread_rwlock_unlock( rwlock );
@@ -43,7 +60,8 @@
r = 0;
}
- sigaction( SIGILL, &oldsa, NULL );
+ sigaction( SIGILL, &oldsa_ill, NULL );
+ sigaction( SIGSEGV, &oldsa_segv, NULL );
return r;
}
|