1 |
dlan 15/03/05 21:24:30 |
2 |
|
3 |
Added: ceph-0.87.1-glibc-2.20.patch |
4 |
Log: |
5 |
fix segfault if using =glibc-2.20, bug 529076 |
6 |
|
7 |
(Portage version: 2.2.17/cvs/Linux x86_64, signed Manifest commit with key 0xAABEFD55) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 sys-cluster/ceph/files/ceph-0.87.1-glibc-2.20.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-cluster/ceph/files/ceph-0.87.1-glibc-2.20.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-cluster/ceph/files/ceph-0.87.1-glibc-2.20.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: ceph-0.87.1-glibc-2.20.patch |
16 |
=================================================================== |
17 |
From cf2104d4d991361c53f6e2fea93b69de10cd654b Mon Sep 17 00:00:00 2001 |
18 |
From: Federico Simoncelli <fsimonce@××××××.com> |
19 |
Date: Sat, 15 Nov 2014 14:14:04 +0000 |
20 |
Subject: [PATCH] common: do not unlock rwlock on destruction |
21 |
|
22 |
According to pthread_rwlock_unlock(3p): |
23 |
|
24 |
Results are undefined if the read-write lock rwlock is not held |
25 |
by the calling thread. |
26 |
|
27 |
and: |
28 |
|
29 |
https://sourceware.org/bugzilla/show_bug.cgi?id=17561 |
30 |
|
31 |
Calling pthread_rwlock_unlock on an rwlock which is not locked |
32 |
is undefined. |
33 |
|
34 |
calling pthread_rwlock_unlock on RWLock destruction could cause |
35 |
an unknown behavior for two reasons: |
36 |
|
37 |
- the lock is acquired by another thread (undefined) |
38 |
- the lock is not acquired (undefined) |
39 |
|
40 |
Moreover since glibc-2.20 calling pthread_rwlock_unlock on a |
41 |
rwlock that is not locked results in a SIGILL that kills the |
42 |
application. |
43 |
|
44 |
This patch removes the pthread_rwlock_unlock call on destruction |
45 |
and replaces it with an assertion to check that the RWLock is |
46 |
not in use. |
47 |
|
48 |
Any code that relied on the implicit release is now going to |
49 |
break the assertion, e.g.: |
50 |
|
51 |
{ |
52 |
RWLock l; |
53 |
l.get(for_write); |
54 |
} // implicit release, wrong. |
55 |
|
56 |
Signed-off-by: Federico Simoncelli <fsimonce@××××××.com> |
57 |
--- |
58 |
src/common/RWLock.h | 4 +++- |
59 |
1 file changed, 3 insertions(+), 1 deletion(-) |
60 |
|
61 |
diff --git a/src/common/RWLock.h b/src/common/RWLock.h |
62 |
index e647e17..6f0ab8e 100644 |
63 |
--- a/src/common/RWLock.h |
64 |
+++ b/src/common/RWLock.h |
65 |
@@ -46,7 +46,9 @@ class RWLock |
66 |
return (nwlock.read() > 0); |
67 |
} |
68 |
virtual ~RWLock() { |
69 |
- pthread_rwlock_unlock(&L); |
70 |
+ // The following check is racy but we are about to destroy |
71 |
+ // the object and we assume that there are no other users. |
72 |
+ assert(!is_locked()); |
73 |
pthread_rwlock_destroy(&L); |
74 |
} |