C ++: Segfault für alle Ladepfadoperationen (OSX / GCC)
Ich erhalte konsistente Fehler bei fast jeder Operation, die ich mit dem Boost-Pfad ausführen möchte.
(Bearbeiten Es scheint, dass alle Segfaulting-Funktionen mit @ zusammenhängecurrent_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;
}
Das obige ist nur ein Beispiel, das folgende auch segfault:auto p = current_path(err);
Undauto p = initial_path(err);
Kompiliert mit:g++-4.9 -lboost_filesystem -lboost_system -std=c++11 main.cpp -o ./path-test
Ausgabe
hello/../world
Segmentation fault: 11
Beide GCC und Boost installiert über Homebrew.
Systemspezifikationen:
OSX: 10.9.4
GCC: 4.9.1
Boost: 1.0.55_2
Bearbeiten
Kompiliert mit-g
und installiert einen Signalhandler laut Kommentar, Ausgabe:
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 Signalhandler (Ausdiese Frag):
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);
}