Summary: | seg fault when non-main thread calls std::current_exception ARMv7-A | ||
---|---|---|---|
Product: | gcc | Reporter: | Philip Deegan <philip.deegan> |
Component: | target | Assignee: | cbaylis |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | webrown.cpp |
Priority: | P3 | ||
Version: | 5.3.0 | ||
Target Milestone: | --- | ||
Host: | Target: | arm-linux-gnueabihf | |
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2016-01-12 00:00:00 | |
Attachments: | Simple seg faulting init |
Description
Philip Deegan
2015-12-08 20:03:47 UTC
Also occurs with a 4.9.2 cross compiler. g++ -v Using built-in specs. COLLECT_GCC=./g++ COLLECT_LTO_WRAPPER=/path/to/gcc_4.9_ARMv7-A/libexec/gcc/arm-linux-gnueabihf/4.9.2/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../tar/gcc-4.9.2/configure --prefix=/path/to/gcc_4.9_ARMv7-A --enable-languages=c,c++ --target=arm-linux-gnueabihf --disable-nls --with-arch=armv7-a Thread model: posix gcc version 4.9.2 (GCC) Also happens on trunk. I'm taking a look at this Anything I can do to help? I managed to look into this in more detail with a colleague. The segfault happens because the implementation of __tls_get_addr in glibc returns an invalid pointer. This seems to be a problem with static linking only, and dynamic linking will avoid the problem. A slightly simplified test case (without the exception handling) is: #include <cstdio> #include <thread> __thread int __attribute__ ((tls_model ("global-dynamic"))) x = 10; class Thread { public: void operator()(){ fprintf(stderr, "testing (%i) ...\n", x); } }; int main(void){ Thread t; std::thread th(std::ref(t)); th.join(); return 0; } If you install a copy of jessie filesystem somewhere on your build machine, you should be able to compile and link against the libraries on that version using --sysroot=/path/to/fs. This should allow you to create dynamically linked binaries which work on your target I've created a glibc bug for this https://sourceware.org/bugzilla/show_bug.cgi?id=19826. Since I don't think this is a bug in gcc, I'll close this bug. |