我正在尝试在使用 clang++ 3.3 libc++ libc++abi 编译的 Ubuntu 12.04 x64 上运行一个简单的程序。
程序:
#include <iostream>
int main(int argc, char **argv) {
try {
std::cerr << "Test cerr \n";
} catch (...) {
std::cout << "catch exception";
}
return 0;
}
写入 std::cerr 会打印消息,但会导致 SIGABRT。
但是,写入 std::cout 可以正常工作。
这里是可执行文件的 ldd 输出:
$ldd cerr_test
linux-vdso.so.1 => (0x00007fffce5ff000)
libc++abi.so.1 => /usr/local/lib/libc++abi.so.1 (0x00007fa4079fd000)
libc++.so.1 => /usr/local/lib/libc++.so.1 (0x00007fa407759000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa40745c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa407246000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa406e87000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa406c69000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa406a61000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa407c55000)
谁能给我一个提示如何解决这个问题?
这是回溯:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Test cerr
Program received signal SIGABRT, Aborted.
0x00007ffff704e425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) backtrace
#0 0x00007ffff704e425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff7051b8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff792a437 in std::uncaught_exception() () from /usr/local/lib/libc++.so.1
#3 0x00007ffff79324e2 in std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry() ()
from /usr/local/lib/libc++.so.1
#4 0x000000000040118e in std::__1::operator<< <std::__1::char_traits<char> > (__os=..., __str=0x401784 "Test cerr \n")
at /usr/local/include/c++/v1/ostream:990
#5 0x0000000000400d41 in main (argc=1, argv=0x7fffffffe728) at cerr_test.cpp:5
(gdb)