diff options
author | Michael Kerrisk <mtk.manpages@gmail.com> | 2015-07-26 22:27:20 +0200 |
---|---|---|
committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2015-07-26 22:27:20 +0200 |
commit | e50eaaf192ecf01d37cd093cf5821dbc44cd7926 (patch) | |
tree | 7555ec8ee31256b40aee1905873a9da3744cd5b8 | |
parent | 0fc33df73d3b46ffd110d15c473af95cdae3ccde (diff) | |
download | man-pages-e50eaaf192ecf01d37cd093cf5821dbc44cd7926.tar.gz |
nptl.7: Note that i386 and x86-64 binaries can't share mutexes
Quoting Nicholas Miell:
PTHREAD_PROCESS_SHARED says any thread with access to the
memory containing the mutex can operate on the mutex and
POSIX basically ignores the idea that different processes
could be running completely incompatible executables or
whatever.
pthread_mutex_t has a bunch of #ifdefs in the middle of it
that change the structure size and layout between i386 and
x86_64.
Most importantly, the positions of the __nusers and __kind
fields are swapped (this looks to be an oversight dating
back to 2003 when __nusers was first introduced and carefully
preserved when the separate i386 and x86_64 versions of
pthreadtypes.h were merged into the single x86 version),
which means that when the lock and unlock functions attempt
to figure out what kind of mutex it is
(recursive/adaptive/whatever), they'll look at the wrong
field if the mutex is from the wrong architecture and then
things will break.
And then there's the fact that the rest of the struct is a
union in the 32-bit version and flat in the 64-bit version,
but that could have been worked around if you put a flag in
the __kind field that tells the 64-bit pthread library that
it is looking at a 32-bit mutex.
Reported-by: Nicholas Miell <nmiell@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r-- | man7/nptl.7 | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/man7/nptl.7 b/man7/nptl.7 index c648591089..80c5cfe497 100644 --- a/man7/nptl.7 +++ b/man7/nptl.7 @@ -114,6 +114,17 @@ and .SH CONFORMING TO For details of the conformance of NPTL to the POSIX standard, see .BR pthreads (7). +.SH NOTES +POSIX says +.\" See POSIX.1-2008 specification of pthread_mutexattr_init() +that any thread in any process with access to the memory +containing a process-shared +.RB ( PTHREAD_PROCESS_SHARED ) +mutex can operate on that mutex. +However, on 64-bit x86 systems, the mutex definition for x86-64 +is incompatible with the mutex definition for i386, +.\" See sysdeps/x86/bits/pthreadtypes.h +meaning that 32-bit and 64-bit binaries can't share mutexes on x86-64 systems. .SH SEE ALSO .BR credentials (7), .BR pthreads (7), |