All of lore.kernel.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nicholas Miell <nmiell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org,
	Carlos O'Donell <carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: For review: nptl(7) man page
Date: Mon, 03 Aug 2015 17:45:40 +0200	[thread overview]
Message-ID: <1438616740.20974.81.camel@localhost.localdomain> (raw)
In-Reply-To: <55B54215.6070502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Sun, 2015-07-26 at 22:24 +0200, Michael Kerrisk (man-pages) wrote:
> On 07/24/2015 05:51 PM, Nicholas Miell wrote:
> > 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.
> 
> Thanks for the additional detail, Nicholas. So, how about a paragraph such 
> as the following for the manual page:
> 
>        POSIX says that any thread in any process with access to the mem‐
>        ory containing a  process-shared  (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  defi‐
>        nition  for  i386,  meaning that 32-bit and 64-bit binaries can't
>        share mutexes on x86-64 systems.

In general, I don't think we promise that one can use share
PTHREAD_PROCESS_SHARED data structures between processes that do not use
the same glibc.  A 32b glibc build and an x86_64 build will differ
(e.g., the new semaphore implemenation uses a different algorithm if 64b
atomic operations are available instead of just 32b ones).  The sizes
and aligment of the data structures are ABI, but I do not believe that
the way in that glibc uses those bits is part of the ABI too.

However, I haven't checked whether POSIX makes any statements about this
situation.

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-08-03 15:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-22 14:38 For review: nptl(7) man page Michael Kerrisk (man-pages)
     [not found] ` <550ED3F4.1080403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-03-22 15:51   ` Bert Wesarg
     [not found]     ` <CAKPyHN2VTcP3eOPA-er+iOs0VCRd4ALzuqPY4HJOVOmDH7Arug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-22 19:02       ` Michael Kerrisk (man-pages)
2015-03-22 19:56 ` Szabolcs Nagy
     [not found]   ` <20150322195632.GM16260-4P1ElwuDYu6sTnJN9+BGXg@public.gmane.org>
2015-07-24  7:56     ` Michael Kerrisk (man-pages)
2015-03-22 21:38 ` Nicholas Miell
     [not found]   ` <550F363B.801-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-24  7:57     ` Michael Kerrisk (man-pages)
     [not found]       ` <CAODz2cDq4o85NOzqCDg9cH8eCvqt3Tq5QXKMMJtXbik5h5bL+Q@mail.gmail.com>
     [not found]         ` <CAODz2cDq4o85NOzqCDg9cH8eCvqt3Tq5QXKMMJtXbik5h5bL+Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-26 20:24           ` Michael Kerrisk (man-pages)
2015-07-26 20:27             ` Nicholas Miell
     [not found]               ` <CAODz2cAmqVtkoNSwUA5p0_=pcFAdrS3ovohyjwnXMapgEhc4qg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-26 20:29                 ` Michael Kerrisk (man-pages)
     [not found]             ` <55B54215.6070502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-03 15:45               ` Torvald Riegel [this message]
2015-08-03 20:08                 ` Rich Felker
2015-08-04 15:06                   ` Roland McGrath
     [not found]                     ` <20150804150648.9E9F42C3B01-j1d2VQoJOwwHfwO+Tb3JRVaTQe2KTcn/@public.gmane.org>
2015-08-04 18:50                       ` Nicholas Miell
     [not found]                         ` <3848244D-C3FE-4FD1-B137-AF7AD6252659-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-05  9:36                           ` Torvald Riegel
     [not found]                             ` <1438767393.20974.211.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-08-05 18:14                               ` Nicholas Miell
     [not found]                                 ` <BCB9D422-563C-4317-B0CB-B14001FE0EA3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-05 18:23                                   ` Rich Felker
     [not found]                                     ` <20150805182327.GA14639-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2015-08-05 18:59                                       ` Michael Kerrisk (man-pages)
     [not found]                                         ` <55C25D2B.4040905-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-05 19:46                                           ` Rich Felker
2015-08-06 10:06                                             ` Michael Kerrisk (man-pages)
     [not found]                                               ` <55C3319A.7020408-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-06 13:54                                                 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438616740.20974.81.camel@localhost.localdomain \
    --to=triegel-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=nmiell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.