Boost logo

Boost Users :

Subject: [Boost-users] [boost][iostreams] Crash when using bzip2 codec
From: Marc Viala (marc.viala_at_[hidden])
Date: 2009-01-17 04:42:05


Hi,

During our migration from Boost 1.34.1 to Boost 1.37.0 we are facing a bug
in bzip2 codec (boost::iostreams::bzip2_compressor &
boost::iostreams::bzip2_compressor).

To demonstrate it, you will find hereafter a code snippet:

#include <fstream>

#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/combine.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/zlib.hpp>

void main()
{
  using namespace boost::iostreams ;

  // Run smoothly
  {
    filtering_stream<bidirectional> chain ;
    chain.push(combine(gzip_decompressor(), gzip_compressor())) ;
    chain.push(std::fstream("test.gz", std::ios::binary|std::ios::out)) ;
    chain << "test" ;
  }

  // Run smoothly
  {
    filtering_stream<bidirectional> chain ;
    chain.push(combine(zlib_decompressor(), zlib_compressor())) ;
    chain.push(std::fstream("test.zip", std::ios::binary|std::ios::out)) ;
    chain << "test" ;
  }

  // Crash in bzip2_decompressor_impl::close
  {
    filtering_stream<bidirectional> chain ;
    chain.push(combine(bzip2_decompressor(), bzip2_compressor())) ;
    chain.push(std::fstream("test.bz2", std::ios::binary|std::ios::out)) ;
    chain << "test" ;
  }
}

The crash in bzip2_decompressor_impl::close is due to an access violation @
line 359 in boost/iostreams/filter/bzip2.hpp. For the other codec, zlib &
gzip, everything runs smoothly.

Set-up:
Boost 1.37.0
Windows XP SP3
Visual C++ 7.1
Bzip2 Library 1.0.5

With Boost 1.34.1 the bzip2 codec seems to run smoothly. Is there any work
around for this codec w/ Boost 1.37.0?

Thanks in advance.

Best regards,

Marc Viala


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