Boost logo

Boost Users :

From: Paul Giaccone (paulg_at_[hidden])
Date: 2006-02-09 10:00:42


Robert Ramey wrote:

>Paul Giaccone wrote:
>
>
>>* is_complete() returns true when the source is a non-existent file
>>* the constructor for xml_iarchive hangs when it is given a stream
>>that has a non-existent file as its source
>>
>>Is this correct behaviour or a bug?
>>
>
>without more information its hard to know. inside of what function is it
>hanging?
>
>
The hang is on this line:

     boost::archive::xml_iarchive input_archive(in); //HANGS

The attached complete program, based on the code I posted originally,
hangs in the same place in Windows (Visual C++ .NET 7.1.3088). I
haven't tested it in Linux (gcc 3.2.3) but the program I was running
when I encountered the problem hung in the same place and is more or
less the same as the one attached.

Note that the attached program deliberately does not check for the
existence of the file in order to enforce the observed behaviour.

Additional info (although this might not be relevant):

Compiler flags:
    /Od /I "W:\boost\boost_1_33_1\include" /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /Fo"Debug/"
/Fd"Debug/vc70.pdb" /W4 /nologo /c /Wp64 /ZI /TP

Link flags:
    /OUT:"Debug/IostreamsTest.exe" /INCREMENTAL /NOLOGO
/LIBPATH:"W:\boost\boost_1_33_1\lib" /DEBUG
/PDB:"Debug/IostreamsTest.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Paul


#include <iostream>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filter/bzip2.hpp>

void load(const std::string& filename)
{
        boost::iostreams::filtering_istream in;
        in.push(boost::iostreams::bzip2_decompressor());
        in.push(boost::iostreams::file_source(filename, BOOST_IOS::in |
                BOOST_IOS::binary));

        if (!in.is_complete())
        {
                std::cerr << "Error creating filtering input stream" <<
                        std::endl;
                return;
        }

        boost::archive::xml_iarchive input_archive(in); //HANGS if

        //deserialise file here
        return;
}

int main(void)
{
        load("not a file"); //this will make load() hang unless the non-existence of the file is caught
}


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