Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 09 Jan 2019 04:18:44 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 234775] PTHREAD_STACK_MIN is too small on amd64
Message-ID:  <bug-234775-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D234775

            Bug ID: 234775
           Summary: PTHREAD_STACK_MIN is too small on amd64
           Product: Base System
           Version: CURRENT
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: markj@FreeBSD.org

The following program segfaults on amd64:

#include <limits.h>
#include <pthread.h>

static void *
fn(void *arg __unused)
{

        return (NULL);
}

int
main(void)
{
        pthread_t t;
        pthread_attr_t attr;

        (void)pthread_attr_init(&attr);
        (void)pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);

        (void)pthread_create(&t, &attr, fn, NULL);
        (void)pthread_join(t, NULL);

        return (0);
}

We end up crashing when the thread exits:

(gdb) bt
#0  symlook_obj1_gnu (req=3D0x7fffdfffd070, obj=3D0x80022a000) at
/home/mark/src/freebsd-dev/libexec/rtld-elf/rtld.c:4463
#1  symlook_obj (req=3D0x7fffdfffd070, obj=3D0x80022a000) at
/home/mark/src/freebsd-dev/libexec/rtld-elf/rtld.c:4272
#2  0x0000000800214357 in symlook_list (req=3D<optimized out>, dlp=3D<optim=
ized
out>, objlist=3D<optimized out>)
    at /home/mark/src/freebsd-dev/libexec/rtld-elf/rtld.c:4197
#3  symlook_global (req=3D0x7fffdfffd6d0, donelist=3D0x7fffdfffd1c0) at
/home/mark/src/freebsd-dev/libexec/rtld-elf/rtld.c:4091
#4  0x000000080020dd3c in symlook_default (req=3D0x7fffdfffd6d0,
refobj=3D0x80022a800) at /home/mark/src/freebsd-dev/libexec/rtld-elf/rtld.c=
:4148
#5  0x000000080020ea73 in do_dlsym (handle=3D0xfffffffffffffffe, name=3D0x8=
0025049b
"_Unwind_ForcedUnwind", retaddr=3D0x800263dbe <_pthread_exit_mask+158>,=20
    ve=3D0x0, flags=3D<error reading variable: Cannot access memory at addr=
ess
0x2>) at /home/mark/src/freebsd-dev/libexec/rtld-elf/rtld.c:3503
#6  0x0000000800263dbe in thread_uw_init () at
/home/mark/src/freebsd-dev/lib/libthr/thread/thr_exit.c:82
#7  _pthread_exit_mask (status=3D0x0, mask=3D0x0) at
/home/mark/src/freebsd-dev/lib/libthr/thread/thr_exit.c:243
#8  0x0000000800263d1b in _pthread_exit (status=3D0x7fffdfffd070) at
/home/mark/src/freebsd-dev/lib/libthr/thread/thr_exit.c:208
#9  0x000000080025675e in thread_start (curthread=3D0x80100a500) at
/home/mark/src/freebsd-dev/lib/libthr/thread/thr_create.c:291
#10 0x0000000000000000 in ?? ()

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-234775-227>