mailing list of musl libc
 help / color / mirror / code / Atom feed
* Segfault when using c++11 thread
@ 2015-08-22 18:03 Dirk Vanden Boer
  2015-08-23 18:35 ` Szabolcs Nagy
  0 siblings, 1 reply; 3+ messages in thread
From: Dirk Vanden Boer @ 2015-08-22 18:03 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

Hi,

I compiled a native x86_64-linux-musl toolchain on my arch linux box using
the musl-cross scripts (no modifications).

When running code that uses c++11 threading functionality I get segfaults:

Minimal reproduction file:
#include <thread>
#include <iostream>

int main()
{
    std::cout << "Thread id: " << std::this_thread::get_id() << std::endl;
}

compile with:
./cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -pthread -std=c++11
-static -g main.cpp -o test

file test
test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically
linked, not stripped

Running test crashes, gdb backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000004006ac in __gthread_self () at
/home/dirk/cross/x86_64-linux-musl/x86_64-linux-musl/include/c++/5.2.0/x86_64-linux-musl/bits/gthr-default.h:686
#2  0x00000000004007ad in std::this_thread::get_id () at
/home/dirk/cross/x86_64-linux-musl/x86_64-linux-musl/include/c++/5.2.0/thread:263
#3  0x00000000004006bc in main () at main.cpp:6

Am I doing something wrong?

Regards,
Dirk

[-- Attachment #2: Type: text/html, Size: 1622 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Segfault when using c++11 thread
  2015-08-22 18:03 Segfault when using c++11 thread Dirk Vanden Boer
@ 2015-08-23 18:35 ` Szabolcs Nagy
  2015-08-23 20:35   ` Dirk Vanden Boer
  0 siblings, 1 reply; 3+ messages in thread
From: Szabolcs Nagy @ 2015-08-23 18:35 UTC (permalink / raw)
  To: Dirk Vanden Boer; +Cc: musl, gregor.richards

* Dirk Vanden Boer <dirk.vdb@gmail.com> [2015-08-22 20:03:28 +0200]:
> I compiled a native x86_64-linux-musl toolchain on my arch linux box using
> the musl-cross scripts (no modifications).
> 
> When running code that uses c++11 threading functionality I get segfaults:
> 
> Minimal reproduction file:
> #include <thread>
> #include <iostream>
> 
> int main()
> {
>     std::cout << "Thread id: " << std::this_thread::get_id() << std::endl;
> }
> 
> compile with:
> ./cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -pthread -std=c++11
> -static -g main.cpp -o test
> 

-static is broken if you don't patch gcc properly
maybe the musl-cross gcc patch is missing the gthr weak ref fix.

(fwiw static linking works for me with the backported
musl patches from gcc-trunk
http://port70.net/~nsz/musl/gcc-5.2.0/gcc-5.2.0-combined.diff
but this link might get broken in the future)

> file test
> test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically
> linked, not stripped
> 
> Running test crashes, gdb backtrace:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000000000 in ?? ()
> (gdb) bt
> #0  0x0000000000000000 in ?? ()
> #1  0x00000000004006ac in __gthread_self () at
> /home/dirk/cross/x86_64-linux-musl/x86_64-linux-musl/include/c++/5.2.0/x86_64-linux-musl/bits/gthr-default.h:686
> #2  0x00000000004007ad in std::this_thread::get_id () at
> /home/dirk/cross/x86_64-linux-musl/x86_64-linux-musl/include/c++/5.2.0/thread:263
> #3  0x00000000004006bc in main () at main.cpp:6
> 
> Am I doing something wrong?
> 
> Regards,
> Dirk


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Segfault when using c++11 thread
  2015-08-23 18:35 ` Szabolcs Nagy
@ 2015-08-23 20:35   ` Dirk Vanden Boer
  0 siblings, 0 replies; 3+ messages in thread
From: Dirk Vanden Boer @ 2015-08-23 20:35 UTC (permalink / raw)
  To: Dirk Vanden Boer, musl, gregor.richards

On Sun, Aug 23, 2015 at 8:35 PM, Szabolcs Nagy <nsz@port70.net> wrote:
>
> * Dirk Vanden Boer <dirk.vdb@gmail.com> [2015-08-22 20:03:28 +0200]:
> > I compiled a native x86_64-linux-musl toolchain on my arch linux box using
> > the musl-cross scripts (no modifications).
> >
> > When running code that uses c++11 threading functionality I get segfaults:
> >
> > Minimal reproduction file:
> > #include <thread>
> > #include <iostream>
> >
> > int main()
> > {
> >     std::cout << "Thread id: " << std::this_thread::get_id() << std::endl;
> > }
> >
> > compile with:
> > ./cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -pthread -std=c++11
> > -static -g main.cpp -o test
> >
>
> -static is broken if you don't patch gcc properly
> maybe the musl-cross gcc patch is missing the gthr weak ref fix.
>
> (fwiw static linking works for me with the backported
> musl patches from gcc-trunk
> http://port70.net/~nsz/musl/gcc-5.2.0/gcc-5.2.0-combined.diff
> but this link might get broken in the future)
>

Thanks, using that patch everything works fine.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-23 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-22 18:03 Segfault when using c++11 thread Dirk Vanden Boer
2015-08-23 18:35 ` Szabolcs Nagy
2015-08-23 20:35   ` Dirk Vanden Boer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).