Hi Daniel,
Daniel Fahlgren wrote,
Hi,
I'm experiencing problems with uClibc-ng when creating static binaries
that uses threads. I originally reported this to the buildroot mailing
list but got redirected here instead.
I have seen your comprehensive bug report.
The problem is when using a combination of stack
protection, threads and
static binaries. The program will during start up get a sigsegv in
__pthread_initialize_minimal_internal(), and gdb says the instruction is
a
mov %fs:0x28,%rax
where %fs is 0x00. The reason for that is that the pthread library is
compiled with stack protection but __pthread_initialize_minimal_internal
is called before __libc_setup_tls in static binaries.
I have created an ugly patch to verify my hypothesis (attached). With
that patch the test program works, but what is the proper way to solve
this issue?
Does this happen only when uClibc itself is compiled with stack
protection? Or just when the pthread app is statically linked and
compiled with -fstack-protector?
With uClibc 0.9.33.x the same thing happens. With
glibc the program
works.
I can reproduce the bug. Moving __libc_setup_tls from NPTL init to
__uClibc_main.c fixes it. Why do you think it is ugly to do this?
Does attached patch works for you? Just a cleaned up version of your
fix. It doesn't produce any regressions running the testsuite.
best regards
Waldemar