我正在尝试使用升压路径执行几乎所有操作的一致性段错误。C++:所有升压路径操作segfault(OSX/GCC)
(编辑:似乎所有段错误的功能都与current_path()
)
Sample program:
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <iostream>
using namespace std;
using namespace boost::filesystem;
using namespace boost::system;
int main(int argc, const char * argv[])
{
error_code err;
auto p = path("hello/../world");
cout << p.string() << endl;
path c = canonical(p, err);
cout << c.string() << endl;
}
上面只是一个例子,下文中也段错误:
auto p = current_path(err);
和:
auto p = initial_path(err);
编译时间:
g++-4.9 -lboost_filesystem -lboost_system -std=c++11 main.cpp -o ./path-test
输出:
hello/../world
Segmentation fault: 11
GCC和经由自制升压型安装。
系统规格:
OSX: 10.9.4
GCC: 4.9.1
Boost: 1.0.55_2
编辑:
编译时-g
并安装了信号处理程序作为每评论,输出:
hello/../world
Segfault:
0 path-test 0x000000010ea215b8 _Z7handleri + 28
1 libsystem_platform.dylib 0x00007fff8b9285aa _sigtramp + 26
2 ??? 0x00007fff67bdf1a1 0x0 + 140734933889441
3 path-test 0x000000010ea2196d _ZN5boost10filesystem9canonicalERKNS0_4pathERNS_6system10error_codeE + 69
4 path-test 0x000000010ea21518 main + 138
5 libdyld.dylib 0x00007fff832c35fd start + 1
6 ??? 0x0000000000000001 0x0 + 1
段错误信号处理程序(取自this question):
void handler(int sig)
{
void *array[10];
size_t size;
size = backtrace(array, 10);
fprintf(stderr, "Segfault:\n");
backtrace_symbols_fd(array, size, STDERR_FILENO);
exit(1);
}
你能告诉我们一个完整的堆栈跟踪吗?先用'-g'构建! – 2014-09-04 11:57:22