Hi all,
I have been using the boost filesystem library for a little while
under NetBSD and all is fine however I have just been porting our
application over to windows and have come across a problem with the
boost filesystem library (Boost 1.33.0). I am compiling with MinGW (g++
3.4.2) on a Windows XP system.
When debugging our application in gdb i get a SIGTRAP with an Invalid
Address specified to RtlFreeHeap. This is when using the
path::native_file_string() method. I also have another problem where a
SEGFAULT ocurrs when using the boost::filesystem::exists() method,
however i think that may be linked to the native_file_string() error.
I wrote a small test program as shown below to reproduce the error when
using path::native_file_string()
#include <iostream>
#include
int main()
{
std::string filename = "test.dat";
boost::filesystem::path boost_filename(filename);
std::cout << "Filename: " << filename << std::endl;
std::cout << "Boost string(): " << boost_filename.string() << std::endl;
std::cout << "Boost native_file_string(): " <<
boost_filename.native_file_string() << std::endl;
return 0;
}
This compiles fine, and it also will run fine outside of GDB. However if
i run it inside GDB i get errors on the line that uses
boost_native_file_string() that are shown below:
Starting program: X:\msys\Utils_test/./a.exe
Program received signal SIGTRAP, Trace/breakpoint trap.
0x7c901231 in _libkernel32_a_iname ()
(gdb) warning: HEAP[a.exe]:
warning: Invalid Address specified to RtlFreeHeap( 003D0000, 003D5138 )
bt
#0 0x7c901231 in _libkernel32_a_iname ()
#1 0x7c96c943 in _libkernel32_a_iname ()
#2 0x7c96cd80 in _libkernel32_a_iname ()
#3 0x7c96df66 in _libkernel32_a_iname ()
#4 0x7c94a5d0 in _libkernel32_a_iname ()
#5 0x7c9268ad in _libkernel32_a_iname ()
#6 0x77c2c2de in _libkernel32_a_iname ()
#7 0x00409855 in operator delete(void*) () at boost_test.cpp:59
#8 0x0042e2dc in std::string::_Rep::_M_destroy(std::allocator<char>
const&) ()
at c:/Boost/include/boost-1_33/boost/filesystem/path.hpp:57
#9 0x00430d68 in std::string::~string() ()
at c:/Boost/include/boost-1_33/boost/filesystem/path.hpp:57
#10 0x004015d6 in main () at boost_test.cpp:12
(gdb)
I also have a larger program where part of its code uses the boost
filesystem library that looks like:
static std::string GetUnusedFileName(const char* suggestion =
"test_file")
{
int count = 0;
std::string base = suggestion;
std::string filename(base + ".dat");
while(boost::filesystem::exists(boost::filesystem::path(filename)))
{
std::ostringstream stream;
stream << base << "_" << count << ".dat";
filename = stream.str();
count++;
}
return filename;
}
This will usually cause a seg fault when calling the
filesystem::exists() method. I currently do not have a stack trace for
that and was unable to reproduce one but i think the two errors may be
linked.
Am i using the system correctly? The code works fine in NetBSD so i
assume so.
Has this bug been identified in the past and possibly fixed for the
1_33_1_beta release? I started compiling that but there are a few
changes i need to make to the build system to go to 1_33_1 that may be
time consuming for a problem that may not yet have been addressed anyway.
Thanks for any help in advance,
Brendon Costa.