This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug dynamic-link/21777] New: use of pthread_getspecific, pthread_setspecific in a statically linked program leads to a crash before main
- From: "bruno at clisp dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Sun, 16 Jul 2017 22:07:25 +0000
- Subject: [Bug dynamic-link/21777] New: use of pthread_getspecific, pthread_setspecific in a statically linked program leads to a crash before main
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=21777
Bug ID: 21777
Summary: use of pthread_getspecific, pthread_setspecific in a
statically linked program leads to a crash before main
Product: glibc
Version: 2.23
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: dynamic-link
Assignee: unassigned at sourceware dot org
Reporter: bruno at clisp dot org
Target Milestone: ---
Created attachment 10265
--> https://sourceware.org/bugzilla/attachment.cgi?id=10265&action=edit
test program
The attached single-threaded program makes use of pthread_getspecific,
pthread_setspecific. When compiled without "-static", it works fine. When
compiled with "-static", it crashes before entering 'main'.
How to reproduce on x86_64:
$ gcc -Wall -O testfstrcmp.c -static -pthread
$ ./a.out
Segmentation fault (core dumped)
It works when compiled without use of pthread_getspecific, pthread_setspecific:
$ gcc -Wall -O -DAVOID_PTHREAD_KEYS testfstrcmp.c -static -pthread
$ ./a.out
>> main
<< main
Here's the stack trace:
$ gcc -Wall -O -ggdb testfstrcmp.c -static -pthread
$ gdb a.out
(gdb) run
Starting program: /tmp/a.out
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) where
#0 0x0000000000000000 in ?? ()
#1 0x000000000049f426 in __register_frame_info.part.4 ()
#2 0x000000000040098d in frame_dummy ()
#3 0x0000000000402557 in __libc_csu_init ()
#4 0x0000000000401b6e in generic_start_main ()
#5 0x0000000000401dba in __libc_start_main ()
#6 0x00000000004008b9 in _start ()
I can also reproduce this crash for other CPUs, using qemu "user mode":
e.g. with mips:
$ mips-linux-gnu-gcc-5 -O -Wall -static testfstrcmp.c -pthread -o
testfstrcmp-mips
$ gdb ~/inst-qemu/2.9.0/bin/qemu-mips
(gdb) run testfstrcmp-mips
Thread 1 "qemu-mips" received signal SIGSEGV, Segmentation fault.
gen_intermediate_code (env=env@entry=0x555557a63f38,
tb=tb@entry=0x7ffff4d21c10) at
/media/develdata/devel/build/qemu-2.9.0/target/mips/translate.c:19962
19962 ctx.opcode = cpu_ldl_code(env, ctx.pc);
or with aarch64:
$ aarch64-linux-gnu-gcc-5 -O -Wall -static testfstrcmp.c -pthread -o
testfstrcmp-aarch64
$ gdb ~/inst-qemu/2.9.0/bin/qemu-aarch64
(gdb) run testfstrcmp-aarch64
Thread 1 "qemu-aarch64" received signal SIGSEGV, Segmentation fault.
0x00005555559c425b in static_code_gen_buffer ()
--
You are receiving this mail because:
You are on the CC list for the bug.