[Bug nptl/22636] New: PTHREAD_STACK_MIN is too small on x86-64

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] New: PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

            Bug ID: 22636
           Summary: PTHREAD_STACK_MIN is too small on x86-64
           Product: glibc
           Version: 2.26
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: fweimer at redhat dot com
                CC: drepper.fsp at gmail dot com
        Depends on: 11787
  Target Milestone: ---
            Target: x86-64
             Flags: security-

If libgcc is not linked with BIND_NOW, a thread stack size of PTHREAD_STACK_MIN
is not enough to cancel this simple thread:

292     static void*
293     my_pthread_warmup_worker(
294             void *thread_args)
295     {
296             (void)thread_args;
297             for (;;)
298                     sleep(10);
299             return NULL;
300     }

(To be clear: This thread runs with a stack size of PTHREAD_STACK_MIN.)

The reason is that we need space for two XSAVE contents (signal handler and
dynamic linker trampoline for libgcc_s).

Apparently, we subtract the guard page and another page from the 16 KiB
request.  Two XSAVE contexts need around 5 KiB, and the libgcc unwinder
required for cancellation needs quite a bit of stack space as well, so that the
remaining 8 KiB are simply not enough.

Linking libgcc_s with BIND_NOW should reduce stack pressure somewhat, and
fixing the guard size accounting would help as well (bug 11787).


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=11787
[Bug 11787] Program with large TLS segments fail.
--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://bugzilla.redhat.com
                   |                            |/show_bug.cgi?id=1527887

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://bugzilla.redhat.com
                   |                            |/show_bug.cgi?id=1527904

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #2 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to [hidden email] from comment #1)
> Remark: increasing PTHREAD_STACK_MIN has in the past been considered to
> require new symbol versions (see the version handling in
> pthread_attr_setstack.c and pthread_attr_setstacksize.c).

Agreed, but in this case I think we don't need to increase PTHREAD_STACK_MIN,
but instead just take up less stack with other things e.g. guard pages, and
static TLS.

I have just reviewed the guard page accounting removal from thread stacks, so
if that goes in we will get a full page back for the stack.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=21236

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=21265

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |22637


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=22637
[Bug 22637] guard size is subtracted from thread stack size instead of adding
it on top
--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl.tools at gmail dot com

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Remark: increasing PTHREAD_STACK_MIN has in the past been considered to
require new symbol versions (see the version handling in
pthread_attr_setstack.c and pthread_attr_setstacksize.c).

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636
Bug 22636 depends on bug 22637, which changed state.

Bug 22637 Summary: guard size is subtracted from thread stack size instead of adding it on top
https://sourceware.org/bugzilla/show_bug.cgi?id=22637

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=22637

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

--- Comment #3 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, master has been updated
       via  f993b8754080ac7572b692870e926d8b493db16c (commit)
      from  09085ede12fb9650f286bdcd805609ae69f80618 (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=f993b8754080ac7572b692870e926d8b493db16c

commit f993b8754080ac7572b692870e926d8b493db16c
Author: Florian Weimer <[hidden email]>
Date:   Wed Jan 10 13:18:04 2018 +0100

    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]

    Disabling lazy binding reduces stack usage during unwinding.

    Note that RTLD_NOW only makes a difference if libgcc.so has not
    already been loaded, so this is only a partial fix.

    Reviewed-by: Adhemerval Zanella <[hidden email]>

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

Summary of changes:
 ChangeLog                          |    6 ++++++
 sysdeps/nptl/unwind-forcedunwind.c |    2 +-
 2 files changed, 7 insertions(+), 1 deletions(-)

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.27

--- Comment #4 from Florian Weimer <fweimer at redhat dot com> ---
I'm closing this as fixed with the additional 4 Kib added by the fix for bug
22637 and the RTLD_NOW change for libgcc_s.so.  (Ideally, distributions should
build that library with BIND_NOW, so that e.g. C++ programs which load it on
startup avoid lazy binding in the unwinder, too.)

In case a future CPU needs closer to 16 KiB (or whatever the PTHREAD_STACK_MIN
value is) of stack to push the signal handler context, we can still throw away
the context as a first step when acting on a cancellation request because we
never return from the signal handler.  But I don't think this is necessary
right now.

If the signal handler context is larger than PTHREAD_STACK_MIN, then we lose,
but that is the nature of a fixed constant.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

--- Comment #5 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, master has been updated
       via  08c6e95234c60a5c2f37532d1111acf084f39345 (commit)
       via  d8b778907e5270fdeb70459842ffbc20bd2ca5e1 (commit)
      from  b303185df9b4f3d097956fe566a32aed4f85b127 (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=08c6e95234c60a5c2f37532d1111acf084f39345

commit 08c6e95234c60a5c2f37532d1111acf084f39345
Author: Florian Weimer <[hidden email]>
Date:   Thu Jan 11 13:13:28 2018 +0100

    csu: Update __libgcc_s_init comment

    Reviewed-by: Carlos O'Donell <[hidden email]>

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

commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1
Author: Florian Weimer <[hidden email]>
Date:   Thu Jan 11 13:13:14 2018 +0100

    nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]

    I verified that without the guard accounting change in commit
    630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
    accounting) and RTLD_NOW for libgcc_s introduced by commit
    f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
    RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
    an AVX-512F machine.  tst-minstack-exit still passes, and either of
    the mentioned commit by itself frees sufficient stack space to make
    tst-minstack-cancel pass, too.

    Reviewed-by: Carlos O'Donell <[hidden email]>

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

Summary of changes:
 ChangeLog                                          |   11 ++++++
 nptl/Makefile                                      |    2 +-
 .../tst-minstack-cancel.c                          |   34 ++++++++++++-------
 .../tst-minstack-exit.c                            |   32 +++++++++++-------
 sysdeps/gnu/unwind-resume.c                        |    8 +++-
 5 files changed, 58 insertions(+), 29 deletions(-)
 copy sysdeps/unix/sysv/linux/tst-sysconf-iov_max.c =>
nptl/tst-minstack-cancel.c (58%)
 copy sysdeps/unix/sysv/linux/tst-sysconf-iov_max.c => nptl/tst-minstack-exit.c
(58%)

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

--- Comment #6 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, master has been updated
       via  860b0240a5645edd6490161de3f8d1d1f2786025 (commit)
      from  16d0f6ac3e43ce2f3703e77bda5ab742d42a5640 (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=860b0240a5645edd6490161de3f8d1d1f2786025

commit 860b0240a5645edd6490161de3f8d1d1f2786025
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 15 15:30:00 2018 +0100

    nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]

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

Summary of changes:
 ChangeLog                  |    8 ++++
 nptl/Makefile              |    7 +++-
 nptl/tst-minstack-throw.cc |   87 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 2 deletions(-)
 create mode 100644 nptl/tst-minstack-throw.cc

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

--- Comment #7 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  247c1ddd309e3f4135045eab554f3817b7d765be (commit)
       via  3feefa1cc80140693581b0ae825dabd145b3cd9a (commit)
       via  89d6a6583367a90ab562207a2180c44a77c658a1 (commit)
       via  0b5cdd80c1e0076b67d0d9689a30589fd59d4d76 (commit)
       via  477cd2b1830c719f2b074f259c28dddcef8687bf (commit)
       via  c247c5366581ce0948de0cde22a49e2bf8c538df (commit)
      from  fabef2edbc29424a8048bdd60eba1a201f95682b (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=247c1ddd309e3f4135045eab554f3817b7d765be

commit 247c1ddd309e3f4135045eab554f3817b7d765be
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 15 15:30:00 2018 +0100

    nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]

    (cherry picked from commit 860b0240a5645edd6490161de3f8d1d1f2786025)

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

commit 3feefa1cc80140693581b0ae825dabd145b3cd9a
Author: Florian Weimer <[hidden email]>
Date:   Thu Jan 11 13:13:14 2018 +0100

    nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]

    I verified that without the guard accounting change in commit
    630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
    accounting) and RTLD_NOW for libgcc_s introduced by commit
    f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
    RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
    an AVX-512F machine.  tst-minstack-exit still passes, and either of
    the mentioned commit by itself frees sufficient stack space to make
    tst-minstack-cancel pass, too.

    Reviewed-by: Carlos O'Donell <[hidden email]>
    (cherry picked from commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1)

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

commit 89d6a6583367a90ab562207a2180c44a77c658a1
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 15 16:05:36 2018 +0100

    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]

    Disabling lazy binding reduces stack usage during unwinding.

    Note that RTLD_NOW only makes a difference if libgcc.so has not
    already been loaded, so this is only a partial fix.

    Reviewed-by: Adhemerval Zanella <[hidden email]>
    (cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)

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

commit 0b5cdd80c1e0076b67d0d9689a30589fd59d4d76
Author: Szabolcs Nagy <[hidden email]>
Date:   Mon Jan 15 16:06:31 2018 +0100

    [BZ #22637] Fix stack guard size accounting

    Previously if user requested S stack and G guard when creating a
    thread, the total mapping was S and the actual available stack was
    S - G - static_tls, which is not what the user requested.

    This patch fixes the guard size accounting by pretending the user
    requested S+G stack.  This way all later logic works out except
    when reporting the user requested stack size (pthread_getattr_np)
    or when computing the minimal stack size (__pthread_get_minstack).

    Normally this will increase thread stack allocations by one page.
    TLS accounting is not affected, that will require a separate fix.

        [BZ #22637]
        * nptl/descr.h (stackblock, stackblock_size): Update comments.
        * nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
        * nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
        stacksize.
        * nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.

    (cherry picked from commit 630f4cc3aa019ede55976ea561f1a7af2f068639)

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

commit 477cd2b1830c719f2b074f259c28dddcef8687bf
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 8 14:57:25 2018 +0100

    nptl: Add test for callee-saved register restore in pthread_exit

    GCC PR 83641 results in a miscompilation of libpthread, which
    causes pthread_exit not to restore callee-saved registers before
    running destructors for objects on the stack.  This test detects
    this situation:

    info: unsigned int, direct pthread_exit call
    tst-thread-exit-clobber.cc:80: numeric comparison failure
       left: 4148288912 (0xf741dd90); from: value
      right: 1600833940 (0x5f6ac994); from: magic_values.v2
    info: double, direct pthread_exit call
    info: unsigned int, indirect pthread_exit call
    info: double, indirect pthread_exit call
    error: 1 test failures

    (cherry picked from commit 579396ee082565ab5f42ff166a264891223b7b82)

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

commit c247c5366581ce0948de0cde22a49e2bf8c538df
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 15 15:23:35 2018 +0100

    Synchronize support/ infrastructure with master

    This commit updates the support/ subdirectory to
    commit 1a51e46e4a87e1cd9528ac5e5656011636e4086b
    on the master branch.

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

Summary of changes:
 ChangeLog                                  |   38 ++++
 NEWS                                       |    2 +
 nptl/Makefile                              |   12 +-
 nptl/allocatestack.c                       |    4 +
 nptl/descr.h                               |    4 +-
 nptl/nptl-init.c                           |    5 +-
 nptl/pthread_getattr_np.c                  |    7 +-
 nptl/tst-minstack-cancel.c                 |   48 +++++
 nptl/tst-minstack-exit.c                   |   46 +++++
 nptl/tst-minstack-throw.cc                 |   87 ++++++++
 nptl/tst-thread-exit-clobber.cc            |  243 +++++++++++++++++++++++
 scripts/backport-support.sh                |    2 +-
 support/Makefile                           |    2 +-
 support/capture_subprocess.h               |    2 +-
 support/check.c                            |    5 +-
 support/check.h                            |   58 +++---
 support/check_addrinfo.c                   |    2 +-
 support/check_dns_packet.c                 |    2 +-
 support/check_hostent.c                    |    2 +-
 support/check_netent.c                     |    2 +-
 support/check_nss.h                        |    2 +-
 support/delayed_exit.c                     |    2 +-
 support/format_nss.h                       |    2 +-
 support/ignore_stderr.c                    |    2 +-
 support/namespace.h                        |    2 +-
 support/next_to_fault.c                    |    2 +-
 support/next_to_fault.h                    |    2 +-
 support/oom_error.c                        |    2 +-
 support/resolv_test.c                      |  298 +++++++++++++++-------------
 support/resolv_test.h                      |    2 +-
 support/run_diff.h                         |    2 +-
 support/set_fortify_handler.c              |    2 +-
 support/support-xfstat.c                   |    2 +-
 support/support-xstat.c                    |    2 +-
 support/support.h                          |    2 +-
 support/support_become_root.c              |    2 +-
 support/support_can_chroot.c               |    2 +-
 support/support_capture_subprocess.c       |    2 +-
 support/support_capture_subprocess_check.c |    2 +-
 support/support_chroot.c                   |    2 +-
 support/support_enter_mount_namespace.c    |    6 +-
 support/support_enter_network_namespace.c  |    2 +-
 support/support_format_address_family.c    |    2 +-
 support/support_format_addrinfo.c          |    2 +-
 support/support_format_dns_packet.c        |    2 +-
 support/support_format_herrno.c            |    2 +-
 support/support_format_hostent.c           |    2 +-
 support/support_format_netent.c            |    2 +-
 support/support_isolate_in_subprocess.c    |    2 +-
 support/support_record_failure.c           |    2 +-
 support/support_run_diff.c                 |    2 +-
 support/support_shared_allocate.c          |    2 +-
 support/support_test_compare_failure.c     |   21 ++-
 support/support_test_main.c                |    2 +-
 support/support_test_verify_impl.c         |    5 +-
 support/support_write_file_string.c        |    2 +-
 support/temp_file-internal.h               |    2 +-
 support/temp_file.c                        |    2 +-
 support/temp_file.h                        |    2 +-
 support/test-driver.c                      |    2 +-
 support/test-driver.h                      |    2 +-
 support/tst-support-namespace.c            |    2 +-
 support/tst-support_capture_subprocess.c   |    2 +-
 support/tst-support_format_dns_packet.c    |    2 +-
 support/tst-support_record_failure-2.sh    |    2 +-
 support/tst-support_record_failure.c       |    2 +-
 support/tst-test_compare.c                 |   20 ++-
 support/tst-xreadlink.c                    |    2 +-
 support/write_message.c                    |    5 +-
 support/xaccept.c                          |    2 +-
 support/xaccept4.c                         |    2 +-
 support/xasprintf.c                        |    2 +-
 support/xbind.c                            |    2 +-
 support/xcalloc.c                          |    2 +-
 support/xchroot.c                          |    2 +-
 support/xclose.c                           |    2 +-
 support/xconnect.c                         |    2 +-
 support/xdlfcn.c                           |    2 +-
 support/xdlfcn.h                           |    2 +-
 support/xdup2.c                            |    2 +-
 support/xfclose.c                          |    2 +-
 support/xfopen.c                           |    2 +-
 support/xfork.c                            |    2 +-
 support/xftruncate.c                       |    2 +-
 support/xgetsockname.c                     |    2 +-
 support/xlisten.c                          |    2 +-
 support/xlseek.c                           |    2 +-
 support/xmalloc.c                          |    2 +-
 support/xmemstream.c                       |    2 +-
 support/xmemstream.h                       |    2 +-
 support/xmkdir.c                           |    2 +-
 support/xmmap.c                            |    2 +-
 support/xmprotect.c                        |    2 +-
 support/xmunmap.c                          |    2 +-
 support/xopen.c                            |    2 +-
 support/xpipe.c                            |    2 +-
 support/xpoll.c                            |    2 +-
 support/xpthread_attr_destroy.c            |    2 +-
 support/xpthread_attr_init.c               |    2 +-
 support/xpthread_attr_setdetachstate.c     |    2 +-
 support/xpthread_attr_setguardsize.c       |    2 +-
 support/xpthread_attr_setstacksize.c       |    2 +-
 support/xpthread_barrier_destroy.c         |    2 +-
 support/xpthread_barrier_init.c            |    2 +-
 support/xpthread_barrier_wait.c            |    2 +-
 support/xpthread_cancel.c                  |    2 +-
 support/xpthread_check_return.c            |    2 +-
 support/xpthread_cond_wait.c               |    2 +-
 support/xpthread_create.c                  |    2 +-
 support/xpthread_detach.c                  |    2 +-
 support/xpthread_join.c                    |    2 +-
 support/xpthread_mutex_consistent.c        |    2 +-
 support/xpthread_mutex_destroy.c           |    2 +-
 support/xpthread_mutex_init.c              |    2 +-
 support/xpthread_mutex_lock.c              |    2 +-
 support/xpthread_mutex_unlock.c            |    2 +-
 support/xpthread_mutexattr_destroy.c       |    2 +-
 support/xpthread_mutexattr_init.c          |    2 +-
 support/xpthread_mutexattr_setprotocol.c   |    2 +-
 support/xpthread_mutexattr_setpshared.c    |    2 +-
 support/xpthread_mutexattr_setrobust.c     |    2 +-
 support/xpthread_mutexattr_settype.c       |    2 +-
 support/xpthread_once.c                    |    2 +-
 support/xpthread_rwlock_init.c             |    2 +-
 support/xpthread_rwlock_rdlock.c           |    2 +-
 support/xpthread_rwlock_unlock.c           |    2 +-
 support/xpthread_rwlock_wrlock.c           |    2 +-
 support/xpthread_rwlockattr_init.c         |    2 +-
 support/xpthread_rwlockattr_setkind_np.c   |    2 +-
 support/xpthread_sigmask.c                 |    2 +-
 support/xpthread_spin_lock.c               |    2 +-
 support/xpthread_spin_unlock.c             |    2 +-
 support/xraise.c                           |    2 +-
 support/xreadlink.c                        |    2 +-
 support/xrealloc.c                         |    2 +-
 support/xrecvfrom.c                        |    2 +-
 support/xsendto.c                          |    2 +-
 support/xsetsockopt.c                      |    2 +-
 support/xsigaction.c                       |    2 +-
 support/xsignal.c                          |    2 +-
 support/xsignal.h                          |    2 +-
 support/xsocket.c                          |    2 +-
 support/xsocket.h                          |    2 +-
 support/xstdio.h                           |    2 +-
 support/xstrdup.c                          |    2 +-
 support/xstrndup.c                         |    2 +-
 support/xsysconf.c                         |    2 +-
 support/xthread.h                          |    2 +-
 support/xunistd.h                          |    2 +-
 support/xunlink.c                          |    2 +-
 support/xwaitpid.c                         |    2 +-
 support/xwrite.c                           |    2 +-
 sysdeps/nptl/unwind-forcedunwind.c         |    2 +-
 153 files changed, 855 insertions(+), 327 deletions(-)
 create mode 100644 nptl/tst-minstack-cancel.c
 create mode 100644 nptl/tst-minstack-exit.c
 create mode 100644 nptl/tst-minstack-throw.cc
 create mode 100644 nptl/tst-thread-exit-clobber.cc

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

--- Comment #8 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.25/master has been updated
       via  abf2e34ee6a9cf1b7e5afddd13971754e5c5fa82 (commit)
       via  8343b9da62a81c6bbdf997f48778793553142f47 (commit)
       via  ea2da72230169601f06944b27ffeb6071e879b7d (commit)
       via  41acd32eb74ed1f93114cad8a49438038eaf42ba (commit)
       via  3e75e676da29d95cf8fbef1b1a441a40cba7ac2b (commit)
       via  5d4c589ca4b527f24f04b8ad23c579499aa510bc (commit)
       via  aedc861c42aa371864c5c64b361181c9bcb872bb (commit)
      from  771c846a71d9ee14aa3b91fd184026482da585d9 (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=abf2e34ee6a9cf1b7e5afddd13971754e5c5fa82

commit abf2e34ee6a9cf1b7e5afddd13971754e5c5fa82
Author: Florian Weimer <[hidden email]>
Date:   Thu Jan 11 13:13:28 2018 +0100

    csu: Update __libgcc_s_init comment

    Reviewed-by: Carlos O'Donell <[hidden email]>
    (cherry picked from commit 08c6e95234c60a5c2f37532d1111acf084f39345)

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

commit 8343b9da62a81c6bbdf997f48778793553142f47
Author: Florian Weimer <[hidden email]>
Date:   Tue Jan 16 07:19:28 2018 +0100

    nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions

    (cherry picked from commit b725132d2b0aeddf970b1ce3e5a24f8637a7b4c2)

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

commit ea2da72230169601f06944b27ffeb6071e879b7d
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 15 15:30:00 2018 +0100

    nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]

    (cherry picked from commit 860b0240a5645edd6490161de3f8d1d1f2786025)

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

commit 41acd32eb74ed1f93114cad8a49438038eaf42ba
Author: Florian Weimer <[hidden email]>
Date:   Thu Jan 11 13:13:14 2018 +0100

    nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]

    I verified that without the guard accounting change in commit
    630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
    accounting) and RTLD_NOW for libgcc_s introduced by commit
    f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
    RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
    an AVX-512F machine.  tst-minstack-exit still passes, and either of
    the mentioned commit by itself frees sufficient stack space to make
    tst-minstack-cancel pass, too.

    Reviewed-by: Carlos O'Donell <[hidden email]>
    (cherry picked from commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1)

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

commit 3e75e676da29d95cf8fbef1b1a441a40cba7ac2b
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 15 16:05:36 2018 +0100

    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]

    Disabling lazy binding reduces stack usage during unwinding.

    Note that RTLD_NOW only makes a difference if libgcc.so has not
    already been loaded, so this is only a partial fix.

    Reviewed-by: Adhemerval Zanella <[hidden email]>
    (cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)

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

commit 5d4c589ca4b527f24f04b8ad23c579499aa510bc
Author: Szabolcs Nagy <[hidden email]>
Date:   Mon Jan 15 16:06:31 2018 +0100

    [BZ #22637] Fix stack guard size accounting

    Previously if user requested S stack and G guard when creating a
    thread, the total mapping was S and the actual available stack was
    S - G - static_tls, which is not what the user requested.

    This patch fixes the guard size accounting by pretending the user
    requested S+G stack.  This way all later logic works out except
    when reporting the user requested stack size (pthread_getattr_np)
    or when computing the minimal stack size (__pthread_get_minstack).

    Normally this will increase thread stack allocations by one page.
    TLS accounting is not affected, that will require a separate fix.

        [BZ #22637]
        * nptl/descr.h (stackblock, stackblock_size): Update comments.
        * nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
        * nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
        stacksize.
        * nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.

    (cherry picked from commit 630f4cc3aa019ede55976ea561f1a7af2f068639)

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

commit aedc861c42aa371864c5c64b361181c9bcb872bb
Author: Florian Weimer <[hidden email]>
Date:   Mon Jan 8 14:57:25 2018 +0100

    nptl: Add test for callee-saved register restore in pthread_exit

    GCC PR 83641 results in a miscompilation of libpthread, which
    causes pthread_exit not to restore callee-saved registers before
    running destructors for objects on the stack.  This test detects
    this situation:

    info: unsigned int, direct pthread_exit call
    tst-thread-exit-clobber.cc:80: numeric comparison failure
       left: 4148288912 (0xf741dd90); from: value
      right: 1600833940 (0x5f6ac994); from: magic_values.v2
    info: double, direct pthread_exit call
    info: unsigned int, indirect pthread_exit call
    info: double, indirect pthread_exit call
    error: 1 test failures

    (cherry picked from commit 579396ee082565ab5f42ff166a264891223b7b82)

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

Summary of changes:
 ChangeLog                          |   48 +++++++
 NEWS                               |    2 +
 nptl/Makefile                      |   14 ++-
 nptl/allocatestack.c               |    4 +
 nptl/descr.h                       |    4 +-
 nptl/nptl-init.c                   |    5 +-
 nptl/pthread_getattr_np.c          |    7 +-
 nptl/tst-minstack-cancel.c         |   48 +++++++
 nptl/tst-minstack-exit.c           |   46 +++++++
 nptl/tst-minstack-throw.cc         |   87 +++++++++++++
 nptl/tst-thread-exit-clobber.cc    |  243 ++++++++++++++++++++++++++++++++++++
 sysdeps/gnu/unwind-resume.c        |    8 +-
 sysdeps/nptl/unwind-forcedunwind.c |    2 +-
 13 files changed, 504 insertions(+), 14 deletions(-)
 create mode 100644 nptl/tst-minstack-cancel.c
 create mode 100644 nptl/tst-minstack-exit.c
 create mode 100644 nptl/tst-minstack-throw.cc
 create mode 100644 nptl/tst-thread-exit-clobber.cc

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/22636] PTHREAD_STACK_MIN is too small on x86-64

tromey at sourceware dot org
In reply to this post by tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=22636

Jeremi <jeremip11 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jeremip11 at gmail dot com

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