summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/threads/assfail.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc/port/threads/assfail.c')
-rw-r--r--usr/src/lib/libc/port/threads/assfail.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/usr/src/lib/libc/port/threads/assfail.c b/usr/src/lib/libc/port/threads/assfail.c
index 54fbe959a0..e37ce4f276 100644
--- a/usr/src/lib/libc/port/threads/assfail.c
+++ b/usr/src/lib/libc/port/threads/assfail.c
@@ -20,12 +20,10 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "thr_uberdata.h"
@@ -161,14 +159,19 @@ ultos(uint64_t n, int base, char *s)
void
lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg)
{
- /* take a snapshot of the mutex before it changes (we hope!) */
- mutex_t mcopy = *mp;
+ mutex_t mcopy;
char buf[800];
uberdata_t *udp;
ulwp_t *self;
lwpid_t lwpid;
pid_t pid;
+ /*
+ * Take a snapshot of the mutex before it changes (we hope!).
+ * Use memcpy() rather than 'mcopy = *mp' in case mp is unaligned.
+ */
+ (void) memcpy(&mcopy, mp, sizeof (mcopy));
+
/* avoid recursion deadlock */
if ((self = __curthread()) != NULL) {
if (assert_thread == self)
@@ -246,8 +249,7 @@ lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg)
void
rwlock_error(const rwlock_t *rp, const char *who, const char *msg)
{
- /* take a snapshot of the rwlock before it changes (we hope) */
- rwlock_t rcopy = *rp;
+ rwlock_t rcopy;
uint32_t rwstate;
char buf[800];
uberdata_t *udp;
@@ -256,6 +258,12 @@ rwlock_error(const rwlock_t *rp, const char *who, const char *msg)
pid_t pid;
int process;
+ /*
+ * Take a snapshot of the rwlock before it changes (we hope!).
+ * Use memcpy() rather than 'rcopy = *rp' in case rp is unaligned.
+ */
+ (void) memcpy(&rcopy, rp, sizeof (rcopy));
+
/* avoid recursion deadlock */
if ((self = __curthread()) != NULL) {
if (assert_thread == self)