|
Boost Users : |
From: Tiago de Paula Peixoto (tiago_at_[hidden])
Date: 2005-10-01 22:01:53
Hello.
I've been experiencing a problem with the bzip2_decompressor filter when
reading from a stream attached to an incomplete file. Instead of
throwing an exception or reaching EOF, the program just hangs.
Consider the following example code (hello.cc) taken from the documentation:
-----------------------------------------------------------
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
int main()
{
using namespace std;
using namespace boost;
using namespace boost::iostreams;
ifstream file("hello.bz2", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(bzip2_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
-----------------------------------------------------------
Suppose this is compiled as "hello". The following command will generate
a simple bzip2-compressed file:
$ echo -e "Hello world\n" | bzip2 > hello-complete.bz2
The next line will copy everything but the last byte from
"hello-complete.bz2" to "hello.bz2":
$ dd if=hello-complete.bz2 of=hello.bz2 bs=1 count=53
So now if the program is run:
$ ./hello
It just hangs in an infinite loop, instead of throwing an exception or
reaching EOF. In the same situation, gzip_decompressor throws an
exception... Is there a reason for this not happening in this case, or
is this just a bug?
I'm using boost 1.33.0 with GCC 4.0.1 on an i686 with GNU/Linux.
Thanks for any help.
-- Tiago de Paula Peixoto <tiago_at_[hidden]>
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