Opened 11 years ago
Closed 11 years ago
#40925 closed defect (wontfix)
libboost (libstdc++) segfault on 10.9 Mavericks
Reported by: | wjngkoh@… | Owned by: | macports-tickets@… |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.2.99 |
Keywords: | mavericks | Cc: | |
Port: |
Description
Hi all,
I encountered a segfault error when I used boost::filesystem with gcc-mp-4.8. Both are installed via MacProts (ports gcc48 and boost.) After upgrading from Mountain Lion to Mavericks, I experienced this problem, so I just formatted my laptop and did clean install Mavericks and MacPorts from SVN again. However, the same problem still persists. Thus, I think it would be an actual bug rather than my mistake, and hope others can also reproduce this problem.
Here is the lldb output of my example code:
% lldb boost_test !244 Current executable set to 'boost_test' (x86_64). (lldb) run Process 7718 launched: '/tmp/boost_test' (x86_64) Process 7718 stopped * thread #1: tid = 0x729956, 0x000000010002fe29 libstdc++.6.dylib`__cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info::__dyncast_result&) const + 35, queue = 'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=1, address=0x9) frame #0: 0x000000010002fe29 libstdc++.6.dylib`__cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info::__dyncast_result&) const + 35 libstdc++.6.dylib`__cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info::__dyncast_result&) const + 35: -> 0x10002fe29: movq 8(%rcx), %rsi 0x10002fe2d: movq %r9, 16(%rsp) 0x10002fe32: movq 96(%rsp), %rbp 0x10002fe37: movq 104(%rsp), %r15 (lldb) list 6 int main() { 7 string src = "boost_test.cpp"; 8 string dst = "boost_test.cpp.bak"; 9 boost::filesystem::exists(dst); 10 boost::filesystem::remove(dst); 11 boost::filesystem::copy_file(src, dst); 12 } (lldb)
The example code I used in this testing is as follows:
#include <iostream> #include <string> #include <boost/filesystem.hpp> using namespace std; int main() { string src = "boost_test.cpp"; string dst = "boost_test.cpp.bak"; boost::filesystem::exists(dst); boost::filesystem::remove(dst); boost::filesystem::copy_file(src, dst); }
and also Makefile.
boost_test: boost_test.cpp g++-mp-4.8 -g -I/opt/local/include -L/opt/local/lib boost_test.cpp -lboost_filesystem-mt -lboost_system-mt -o boost_test
Change History (6)
comment:1 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)
comment:2 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)
Keywords: | mavericks added |
---|
comment:3 follow-up: 4 Changed 11 years ago by wjngkoh@…
Doesn't libc++ have ABI compatibility with libstdc++? I assumed it because I used the same source code in the exactly same way on 10.8 with MacPorts 2.2 without any problem. Anyway, thanks for your comment, ryandesign@. I will try new libboost compiled by gcc 4.8 instead of the system-default CC.
comment:4 follow-up: 5 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)
Replying to wjngkoh@…:
Doesn't libc++ have ABI compatibility with libstdc++?
No. They are API-compatible, but not ABI-compatible.
I assumed it because I used the same source code in the exactly same way on 10.8 with MacPorts 2.2 without any problem.
OS X 10.9 Mavericks is the first version to use libc++; previous versions of OS X used libstdc++.
Anyway, thanks for your comment, ryandesign@. I will try new libboost compiled by gcc 4.8 instead of the system-default CC.
Instead, could you compile your code using the system compiler? That might be better.
comment:5 Changed 11 years ago by larryv (Lawrence Velázquez)
Replying to ryandesign@…:
No. They are API-compatible, but not ABI-compatible.
To elaborate, my understanding is that the libstdc++ included with earlier versions of OS X was patched by Apple to use libc++abi, which is the same C++ ABI used by libc++. However, libstdc++ as installed by MacPorts uses its own C++ ABI, libsupc++. Thus, C++ code compiled with MacPorts’ GCC compilers is ABI-incompatible with C++ code compiled with Apple’s compilers.
comment:6 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Is this the problem of mixing libc++ (which boost uses because it's compiled with the system compiler) with libstdc++ (which gcc48 uses)? You can't mix C++ runtimes...