Boost logo

Boost Users :

From: Aubrey, Jason (jason.aubrey_at_[hidden])
Date: 2006-10-31 12:14:52


Hi,

When I run the following program it runs successfully but throws an
exception during shutdown. I don't know why, but it seems that the call
to boost::filesystem::file_size() is corrupting memory somehow. This
example only shows the call to file_size() but I think I've seen similar
trouble with other calls within boost::filesystem.

Am I doing something wrong here or is this a bug?

Regards,
Jason Aubrey

----------------------

Environment:
        OS: Win2k
        Compiler: VS7.1
        Boost: v1.33.1

----------------------

#include <boost/filesystem/operations.hpp>
#include <fstream>

int main(int, char**)
{
    // Create a file
    using namespace std;
    const string fileName("/temp/test.txt");
    ofstream file;
    file.open(fileName.c_str());
    const string message("this is a test");
    file << message;
    file.close();

    const boost::intmax_t fileSize =
boost::filesystem::file_size(fileName);

    if( fileSize != message.size() )
        throw std::exception("Bad result");

    return 0;
}

----------------------
The following pop-up occurs during program completion:

Window Title="Microsoft Visual C++ Debug Library"
Window Icon=Critical Error
Window Text="
        Debug Assertion Failed!
        Program: ....
        File: dbgdel.cpp
        Line: 52
        
        Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
        
        For information on how your program can cause an assertion
failure,
        see the Visual C++ documentation on asserts.
        
        (Press Retry to debug the application)"
Buttons=[Abort] [Retry] [Ignore]


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