This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/22298] x32: lockups on recursive pthread_mutex_lock after upgrade to 2.26


https://sourceware.org/bugzilla/show_bug.cgi?id=22298

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.26/master has been updated
       via  a81c1156c1a9a6161d49b295a09a4e4cff7a88d0 (commit)
       via  5712f8db265a75132dde7ffa4b5aab41c89a6b89 (commit)
       via  bfdb34f2f26933a831684c09cadc2b782f7fbd7a (commit)
       via  f8ee700e8959236bb2c54f3aacf57edca5dab186 (commit)
      from  caa6857ec1087c705b11d8000716fbc67152e428 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a81c1156c1a9a6161d49b295a09a4e4cff7a88d0

commit a81c1156c1a9a6161d49b295a09a4e4cff7a88d0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Oct 19 10:11:57 2017 -0200

    nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND,USE_UNION}

    This patch adds two new internal defines to set the internal
    pthread_mutex_t layout required by the supported ABIS:

      1. __PTHREAD_MUTEX_NUSERS_AFTER_KIND which control whether to define
         __nusers fields before or after __kind.  The preferred value for
         is 0 for new ports and it sets __nusers before __kind.

      2. __PTHREAD_MUTEX_USE_UNION which control whether internal __spins and
         __list members will be place inside an union for linuxthreads
         compatibility.  The preferred value is 0 for ports and it sets
         to not use an union to define both fields.

    It fixes the wrong offsets value for __kind value on x86_64-linux-gnu-x32.
    Checked with a make check run-built-tests=no on all afected ABIs.

        [BZ #22298]
        * nptl/allocatestack.c (allocate_stack): Check if
        __PTHREAD_MUTEX_HAVE_PREV is non-zero, instead if
        __PTHREAD_MUTEX_HAVE_PREV is defined.
        * nptl/descr.h (pthread): Likewise.
        * nptl/nptl-init.c (__pthread_initialize_minimal_internal):
        Likewise.
        * nptl/pthread_create.c (START_THREAD_DEFN): Likewise.
        * sysdeps/nptl/fork.c (__libc_fork): Likewise.
        * sysdeps/nptl/pthread.h (PTHREAD_MUTEX_INITIALIZER): Likewise.
        * sysdeps/nptl/bits/thread-shared-types.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New
        defines.
        (__pthread_internal_list): Check __PTHREAD_MUTEX_USE_UNION instead
        of __WORDSIZE for internal layout.
        (__pthread_mutex_s): Check __PTHREAD_MUTEX_NUSERS_AFTER_KIND instead
        of __WORDSIZE for internal __nusers layout and
__PTHREAD_MUTEX_USE_UNION
        instead of __WORDSIZE whether to use an union for __spins and __list
        fields.
        (__PTHREAD_MUTEX_HAVE_PREV): Define also for __PTHREAD_MUTEX_USE_UNION
        case.
        * sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New
        defines.
        * sysdeps/alpha/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/arm/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/hppa/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/ia64/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/m68k/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/mips/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/nios2/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/s390/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/sh/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/sparc/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/tile/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.
        * sysdeps/x86/nptl/bits/pthreadtypes-arch.h
        (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
        Likewise.

    Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

    (cherry picked from commit 06be6368da16104be51ebf23f7c68a51f321673f)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5712f8db265a75132dde7ffa4b5aab41c89a6b89

commit 5712f8db265a75132dde7ffa4b5aab41c89a6b89
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Oct 16 14:27:29 2017 -0200

    nptl: Add tests for internal pthread_mutex_t offsets

    This patch adds a new build test to check for internal fields
    offsets for user visible internal field.  Although currently
    the only field which is statically initialized to a non zero value
    is pthread_mutex_t.__data.__kind value, the tests also check the
    offset of __kind, __spins, __elision (if supported), and __list
    internal member.  A internal header (pthread-offset.h) is added
    to each major ABI with the reference value.

    Checked on x86_64-linux-gnu and with a build check for all affected
    ABIs (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
    hppa-linux-gnu, i686-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
    microblaze-linux-gnu, mips64-linux-gnu, mips64-n32-linux-gnu,
    mips-linux-gnu, powerpc64le-linux-gnu, powerpc-linux-gnu,
    s390-linux-gnu, s390x-linux-gnu, sh4-linux-gnu, sparc64-linux-gnu,
    sparcv9-linux-gnu, tilegx-linux-gnu, tilegx-linux-gnu-x32,
    tilepro-linux-gnu, x86_64-linux-gnu, and x86_64-linux-x32).

        * nptl/pthreadP.h (ASSERT_PTHREAD_STRING,
        ASSERT_PTHREAD_INTERNAL_OFFSET): New macro.
        * nptl/pthread_mutex_init.c (__pthread_mutex_init): Add build time
        checks for internal pthread_mutex_t offsets.
        * sysdeps/aarch64/nptl/pthread-offsets.h
        (__PTHREAD_MUTEX_NUSERS_OFFSET, __PTHREAD_MUTEX_KIND_OFFSET,
        __PTHREAD_MUTEX_SPINS_OFFSET, __PTHREAD_MUTEX_ELISION_OFFSET,
        __PTHREAD_MUTEX_LIST_OFFSET): New macro.
        * sysdeps/alpha/nptl/pthread-offsets.h: Likewise.
        * sysdeps/arm/nptl/pthread-offsets.h: Likewise.
        * sysdeps/hppa/nptl/pthread-offsets.h: Likewise.
        * sysdeps/i386/nptl/pthread-offsets.h: Likewise.
        * sysdeps/ia64/nptl/pthread-offsets.h: Likewise.
        * sysdeps/m68k/nptl/pthread-offsets.h: Likewise.
        * sysdeps/microblaze/nptl/pthread-offsets.h: Likewise.
        * sysdeps/mips/nptl/pthread-offsets.h: Likewise.
        * sysdeps/nios2/nptl/pthread-offsets.h: Likewise.
        * sysdeps/powerpc/nptl/pthread-offsets.h: Likewise.
        * sysdeps/s390/nptl/pthread-offsets.h: Likewise.
        * sysdeps/sh/nptl/pthread-offsets.h: Likewise.
        * sysdeps/sparc/nptl/pthread-offsets.h: Likewise.
        * sysdeps/tile/nptl/pthread-offsets.h: Likewise.
        * sysdeps/x86_64/nptl/pthread-offsets.h: Likewise.

    Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

    (cherry picked from commit dff91cd45e35e47d567274331f3deb8e87a188c9)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bfdb34f2f26933a831684c09cadc2b782f7fbd7a

commit bfdb34f2f26933a831684c09cadc2b782f7fbd7a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sat Oct 21 11:33:27 2017 -0200

    posix: Do not use WNOHANG in waitpid call for Linux posix_spawn

    As shown in some buildbot issues on aarch64 and powerpc, calling
    clone (VFORK) and waitpid (WNOHANG) does not guarantee the child
    is ready to be collected.  This patch changes the call back to 0
    as before fe05e1cb6d64 fix.

    This change can lead to the scenario 4.3 described in the commit,
    where the waitpid call can hang undefinitely on the call.  However
    this is also a very unlikely and also undefinied situation where
    both the caller is trying to terminate a pid before posix_spawn
    returns and the race pid reuse is triggered.  I don't see how to
    correct handle this specific situation within posix_spawn.

    Checked on x86_64-linux-gnu, aarch64-linux-gnu and
    powerpc64-linux-gnu.

        * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Use 0 instead of
        WNOHANG in waitpid call.

    (cherry picked from commit aa95a2414e4f664ca740ad5f4a72d9145abbd426)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f8ee700e8959236bb2c54f3aacf57edca5dab186

commit f8ee700e8959236bb2c54f3aacf57edca5dab186
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Oct 12 15:20:57 2017 -0300

    posix: Fix improper assert in Linux posix_spawn (BZ#22273)

    As noted by Florian Weimer, current Linux posix_spawn implementation
    can trigger an assert if the auxiliary process is terminated before
    actually setting the err member:

        340   /* Child must set args.err to something non-negative - we rely on
        341      the parent and child sharing VM.  */
        342   args.err = -1;
        [...]
        362   new_pid = CLONE (__spawni_child, STACK (stack, stack_size),
stack_size,
        363                    CLONE_VM | CLONE_VFORK | SIGCHLD, &args);
        364
        365   if (new_pid > 0)
        366     {
        367       ec = args.err;
        368       assert (ec >= 0);

    Another possible issue is killing the child between setting the err and
    actually calling execve.  In this case the process will not ran, but
    posix_spawn also will not report any error:

        269
        270   args->err = 0;
        271   args->exec (args->file, args->argv, args->envp);

    As suggested by Andreas Schwab, this patch removes the faulty assert
    and also handles any signal that happens before fork and execve as the
    spawn was successful (and thus relaying the handling to the caller to
    figure this out).  Different than Florian, I can not see why using
    atomics to set err would help here, essentially the code runs
    sequentially (due CLONE_VFORK) and I think it would not be legal the
    compiler evaluate ec without checking for new_pid result (thus there
    is no need to compiler barrier).

    Summarizing the possible scenarios on posix_spawn execution, we
    have:

      1. For default case with a success execution, args.err will be 0, pid
         will not be collected and it will be reported to caller.

      2. For default failure case, args.err will be positive and the it will
         be collected by the waitpid.  An error will be reported to the
         caller.

      3. For the unlikely case where the process was terminated and not
         collected by a caller signal handler, it will be reported as succeful
         execution and not be collected by posix_spawn (since args.err will
         be 0). The caller will need to actually handle this case.

      4. For the unlikely case where the process was terminated and collected
         by caller we have 3 other possible scenarios:

         4.1. The auxiliary process was terminated with args.err equal to 0:
          it will handled as 1. (so it does not matter if we hit the pid
              reuse race since we won't possible collect an unexpected
              process).

         4.2. The auxiliary process was terminated after execve (due a failure
              in calling it) and before setting args.err to -1: it will also
              be handle as 1. but with the issue of not be able to report the
              caller a possible execve failures.

         4.3. The auxiliary process was terminated after args.err is set to -1:
              this is the case where it will be possible to hit the pid reuse
              case where we will need to collected the auxiliary pid but we
              can not be sure if it will be expected one.  I think for this
              case we need to actually change waitpid to use WNOHANG to avoid
              hanging indefinitely on the call and report an error to caller
              since we can't differentiate between a default failure as 2.
              and a possible pid reuse race issue.

    Checked on x86_64-linux-gnu.

        * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Handle the case where
        the auxiliary process is terminated by a signal before calling _exit
        or execve.

    (cherry picked from commit fe05e1cb6d64dba6172249c79526f1e9af8f2bfd)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                        |  101 ++++++++++++++++++++++
 nptl/allocatestack.c                             |    2 +-
 nptl/descr.h                                     |    2 +-
 nptl/nptl-init.c                                 |    2 +-
 nptl/pthreadP.h                                  |    6 ++
 nptl/pthread_create.c                            |    4 +-
 nptl/pthread_mutex_init.c                        |   13 +++
 sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h    |    2 +
 sysdeps/aarch64/nptl/pthread-offsets.h           |    5 +
 sysdeps/alpha/nptl/bits/pthreadtypes-arch.h      |    2 +
 sysdeps/alpha/nptl/pthread-offsets.h             |    5 +
 sysdeps/arm/nptl/bits/pthreadtypes-arch.h        |    2 +
 sysdeps/arm/nptl/pthread-offsets.h               |    5 +
 sysdeps/hppa/nptl/bits/pthreadtypes-arch.h       |    2 +
 sysdeps/hppa/nptl/pthread-offsets.h              |    5 +
 sysdeps/i386/nptl/pthread-offsets.h              |    5 +
 sysdeps/ia64/nptl/bits/pthreadtypes-arch.h       |    2 +
 sysdeps/ia64/nptl/pthread-offsets.h              |    5 +
 sysdeps/m68k/nptl/bits/pthreadtypes-arch.h       |    2 +
 sysdeps/m68k/nptl/pthread-offsets.h              |    5 +
 sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h |    2 +
 sysdeps/microblaze/nptl/pthread-offsets.h        |    5 +
 sysdeps/mips/nptl/bits/pthreadtypes-arch.h       |    2 +
 sysdeps/mips/nptl/pthread-offsets.h              |   13 +++
 sysdeps/nios2/nptl/bits/pthreadtypes-arch.h      |    2 +
 sysdeps/nios2/nptl/pthread-offsets.h             |    5 +
 sysdeps/nptl/bits/thread-shared-types.h          |   32 ++++++-
 sysdeps/nptl/fork.c                              |    2 +-
 sysdeps/nptl/pthread.h                           |    2 +-
 sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h    |    2 +
 sysdeps/powerpc/nptl/pthread-offsets.h           |   15 +++
 sysdeps/s390/nptl/bits/pthreadtypes-arch.h       |    2 +
 sysdeps/s390/nptl/pthread-offsets.h              |   15 +++
 sysdeps/sh/nptl/bits/pthreadtypes-arch.h         |    2 +
 sysdeps/sh/nptl/pthread-offsets.h                |    5 +
 sysdeps/sparc/nptl/bits/pthreadtypes-arch.h      |    2 +
 sysdeps/sparc/nptl/pthread-offsets.h             |   15 +++
 sysdeps/tile/nptl/bits/pthreadtypes-arch.h       |    2 +
 sysdeps/tile/nptl/pthread-offsets.h              |   15 +++
 sysdeps/unix/sysv/linux/spawni.c                 |   24 ++++--
 sysdeps/x86/nptl/bits/pthreadtypes-arch.h        |    7 ++
 sysdeps/x86_64/nptl/pthread-offsets.h            |    5 +
 42 files changed, 335 insertions(+), 18 deletions(-)
 create mode 100644 sysdeps/aarch64/nptl/pthread-offsets.h
 create mode 100644 sysdeps/alpha/nptl/pthread-offsets.h
 create mode 100644 sysdeps/arm/nptl/pthread-offsets.h
 create mode 100644 sysdeps/hppa/nptl/pthread-offsets.h
 create mode 100644 sysdeps/i386/nptl/pthread-offsets.h
 create mode 100644 sysdeps/ia64/nptl/pthread-offsets.h
 create mode 100644 sysdeps/m68k/nptl/pthread-offsets.h
 create mode 100644 sysdeps/microblaze/nptl/pthread-offsets.h
 create mode 100644 sysdeps/mips/nptl/pthread-offsets.h
 create mode 100644 sysdeps/nios2/nptl/pthread-offsets.h
 create mode 100644 sysdeps/powerpc/nptl/pthread-offsets.h
 create mode 100644 sysdeps/s390/nptl/pthread-offsets.h
 create mode 100644 sysdeps/sh/nptl/pthread-offsets.h
 create mode 100644 sysdeps/sparc/nptl/pthread-offsets.h
 create mode 100644 sysdeps/tile/nptl/pthread-offsets.h
 create mode 100644 sysdeps/x86_64/nptl/pthread-offsets.h

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]