简体   繁体   中英

Crash when using boost::iostreams

I'm trying to use boost::iostreams(1.53.0) to uncompress a HTTP request body and later process it. But I get a crash when I run the following code.

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;
}

The crash occurs in gzip_decompressor() , more specifically in gzip_header() { reset(); } gzip_header() { reset(); } from boost's gzip.hpp (by looking at the call stack).

I have compiled myself the boost::iostreams library and also tried to use boost from macports, but the same crash occurs. I also tried using the gzstream library , but that crashes also in a constructor, more specifically in the constructor of igzstream .

I tend to believe that this is a zlib-related problem. I didn't specify, I'm using a MacBook Pro with Mountain Lion and xCode 4.6 to build and run the code.

Did any of you encounter such a problem before?

I found the problem: Apple's LLVM compiler. I was sure I was using GCC, but it seems I wasn't.

I discovered this by stumbling upon another weird crash, which happened just by instantiating a std::string object. This made me check the project settings, where I found I was using the LLVM compiler, which probably wasn't happy with me linking gcc-built libraries.

Thanks for your replies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM