[iostreams] problem with bzip2_decompressor and incomplete files

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@forked.de>

Tiago de Paula Peixoto wrote:
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.
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?
It's a bug. Thanks for reporting it.
Thanks for any help. -- Tiago de Paula Peixoto <tiago@forked.de>
-- Jonathan Turkanis www.kangaroologic.com
participants (1)
-
Jonathan Turkanis
-
Tiago de Paula Peixoto