I am getting consistent segfaults with almost any operation I am trying to perform with boost path.
(Edit: It appears that all segfaulting functions are related to 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;
}
The above is just an example, the following also segfault:
auto p = current_path(err);
And:
auto p = initial_path(err);
Compiled with:
g++-4.9 -lboost_filesystem -lboost_system -std=c++11 main.cpp -o ./path-test
Output:
hello/../world
Segmentation fault: 11
Both GCC and Boost installed via Homebrew.
System specs:
OSX: 10.9.4
GCC: 4.9.1
Boost: 1.0.55_2
Edit:
Compiled with -g
and installed a signal handler as per comment, output:
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
Segfault signal handler (Taken from 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);
}