2013-04-01 35 views
1

我想使用boost :: iostreams(1.53.0)解压缩HTTP请求正文,并稍后处理它。 但是当我运行下面的代码时发生崩溃。发生当使用boost :: iostreams时崩溃

try { 
    using namespace boost::iostreams; 
    ifstream file(argv[1], std::ios_base::in | std::ios_base::binary); 
    boost::iostreams::filtering_istream in; 
    in.push(gzip_decompressor()); 
    in.push(file); 
    std::stringstream strstream; 
    boost::iostreams::copy(in, strstream); 
} catch (std::exception& e) { 
    cout << e.what() << endl; 
} 

的崩溃gzip_decompressor(),更具体地说是在gzip_header() { reset(); }从升压转换器的gzip.hpp(通过查看调用堆栈)。

我编译了自己的boost :: iostreams库,并试图从macports使用boost,但同样的崩溃发生。我也尝试过使用gzstream library,但在构造函数中崩溃,更具体地在igzstream的构造函数中崩溃。

我倾向于认为这是与zlib相关的问题。 我没有指定,我正在使用Mountain Lion和xCode 4.6的MacBook Pro来构建和运行代码。

你们有没有遇到过这样的问题?

+0

你可以附加一个调试器并发布崩溃的堆栈跟踪吗? –

+0

您是否确认argv [1]实际上指向一个文件? – Zac

+0

@Zac gzip_decompressor()崩溃与提供的argv无关。尽管如此,它指向了一个正确的文件路径。 – afp

回答

1

我发现问题:Apple的LLVM编译器。 我确定我在使用GCC,但看起来我并不是。

我发现了这个磕磕绊绊的另一个奇怪的崩溃,发生只是通过实例化一个std::string对象。这让我检查了项目设置,在那里我发现我正在使用LLVM编译器,这可能对链接gcc构建的库并不满意。

感谢您的回复。