Boost logo

Boost Users :

Subject: [Boost-users] [Iostreams] Problem with filtering_istream and gzip_decompressor with 64bit
From: peterbarnabus (peterbarnabus_at_[hidden])
Date: 2010-04-16 10:38:22


Hi,

I am trying to use the iostream gzip filters, and have run into some problems using them with 64bit compilers. I am using OSX 10.6 and my code works just fine with apples gcc-4.2 compilers in both 32 and 64 bit mode. However, with gcc4.4 or gcc4.5 compilers, it runs only in 32bit mode and crashes in 64bit mode.

Has anyone run into this issue? Is it a problem with how I am using the iostream library? Here is the code to reproduce:

$ g++-mp-4.4 -m64 -g -O0 -o test_iostreams.4.4-64 test_iostreams_64.C -I/opt/local/include/boost/ -I/opt/local/include/ -L/opt/local/lib/ -lboost_iostreams-mt

If I run the 64bit executable I get this message (for the 32bit it just echo's the file correctly):

$ ./test_iostreams.4.4-64
test_iostreams.4.4-64(38367) malloc: *** error for object 0x100164dc0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
^CAbort trap

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file.hpp>

namespace io = boost::iostreams;
using namespace std;

void test()
{
 string filename("/tmp/g.dot.gz");

 istream *ifs = new io::filtering_istream();
 ((io::filtering_istream *) ifs)->push(io::gzip_decompressor());
 ((io::filtering_istream *) ifs)->push(io::file_source(filename));

 string str;

 while( std::getline((*ifs), str) ) {
   std::cout << "read line : " << str << std::endl;
 }
}

int main(int argc, char **argv)
{
 test();
 return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net