Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 622694 - =sys-libs/glibc-2.24-r3 on ia64 crashes on thread exit: signal SIGSEGV, Segmentation fault: pthread_create.c:432: __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
Summary: =sys-libs/glibc-2.24-r3 on ia64 crashes on thread exit: signal SIGSEGV, Segme...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL: https://sourceware.org/bugzilla/show_...
Whiteboard:
Keywords: PATCH
Depends on: 657148
Blocks:
  Show dependency tree
 
Reported: 2017-06-25 14:38 UTC by Sergei Trofimovich (RETIRED)
Modified: 2018-06-02 21:52 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
0001-fix-pthread_create-crash-in-ia64.patch (0001-fix-pthread_create-crash-in-ia64.patch,2.74 KB, patch)
2017-06-25 22:03 UTC, Sergei Trofimovich (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2017-06-25 14:38:18 UTC
The tets file:

$ cat bug.c 
    // how to crash: gcc -O0 -ggdb3 -o r bug.c -pthread && ./r

    #include <pthread.h>

    static void * f (void * p)
    {
        return NULL;
    }

    int main (int argc, const char ** argv)
    {
        pthread_t t;
        pthread_create (&t, NULL, &f, NULL);

        pthread_join (t, NULL);
        return 0;
    }

How to crash:
$ gcc -O0 -ggdb3 -o r bug.c -pthread && ./r
Segmentation fault (core dumped)

$  gdb r core
...
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x2000000000077da0 in start_thread (arg=0x0) at pthread_create.c:432
432         __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
[Current thread is 1 (Thread 0x2000000000b6b1f0 (LWP 20912))]

(gdb) list
427     #ifdef _STACK_GROWS_DOWN
428       char *sp = CURRENT_STACK_FRAME;
429       size_t freesize = (sp - (char *) pd->stackblock) & ~pagesize_m1;
430       assert (freesize < pd->stackblock_size);
431       if (freesize > PTHREAD_STACK_MIN)
432         __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
433     #else
434       /* Page aligned start of memory to free (higher than or equal
435          to current sp plus the minimum stack size).  */
436       void *freeblock = (void*)((size_t)(CURRENT_STACK_FRAME

#0  0x2000000000077da0 in start_thread (arg=0x0) at pthread_create.c:432
        pd = 0x0
        now = <optimized out>
        unwind_buf = <error reading variable unwind_buf (Cannot access memory at address 0xfffffffffffffd90)>
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = 0x2000000000b6a870 ""
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#1  0x0000000000000000 in ?? ()
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2017-06-25 22:03:28 UTC
Filed https://sourceware.org/bugzilla/show_bug.cgi?id=21672 upstream and attached patch.
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2017-06-25 22:03:55 UTC
Created attachment 478018 [details, diff]
0001-fix-pthread_create-crash-in-ia64.patch
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2017-06-27 09:58:53 UTC
http://trofi.github.io/posts/202-stack-growth-direction-how-hard-can-it-be.html on why I think patch works :)
Comment 4 Andreas K. Hüttel archtester gentoo-dev 2017-09-11 11:42:19 UTC
Added to 2.26 patchset (>=1)
Comment 5 Larry the Git Cow gentoo-dev 2017-11-12 14:16:41 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02056778ea5961e77a59a7a246b355c1225c7404

commit 02056778ea5961e77a59a7a246b355c1225c7404
Author:     Andreas K. Hüttel <dilfridge@gentoo.org>
AuthorDate: 2017-11-12 12:28:38 +0000
Commit:     Andreas K. Hüttel <dilfridge@gentoo.org>
CommitDate: 2017-11-12 14:15:28 +0000

    sys-libs/glibc: Re-add keywords to glibc 2.26
    
    Bug: https://bugs.gentoo.org/492814
    Bug: https://bugs.gentoo.org/622694
    Bug: https://bugs.gentoo.org/617938
    Bug: https://bugs.gentoo.org/466176
    Bug: https://bugs.gentoo.org/628768
    Bug: https://bugs.gentoo.org/637016
    Bug: https://bugs.gentoo.org/636934
    Bug: https://bugs.gentoo.org/381391
    Bug: https://bugs.gentoo.org/636158
    Package-Manager: Portage-2.3.13, Repoman-2.3.4

 sys-libs/glibc/glibc-2.26-r3.ebuild | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)}
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2018-06-02 21:52:37 UTC
sys-libs/glibc-2.26-r7 was stabled with fix included in bug #657148