Ticket #6638 (new Bugs)

Opened 3 years ago

Last modified 18 months ago

convert_aux fails while intializing global variable

Reported by: john doe <johndoe> Owned by: bemandawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.49.0 Severity: Problem
Keywords: filesystem path convert wide/narrow string Cc:



convert_aux fails in global scope:

Trying to initialize global path variable by concatenating '/' a wide string path w/ narrow string path fails!

"Unhandled exception at 0x0f8bc688 (msvcp100d.dll) in paths.exe: 0xC0000005: Access violation reading location 0x00000000."

If initializing inside main() scope everything works fine. I think this worked as expected in previous version(s) 1.48.. no luck with 1.49 though :(

Additional info: WIN 32 and 64 bit, MSVS2010

#include <iostream>
#include <boost/filesystem.hpp>

using namespace boost::filesystem;

path p(L"C:\\TEMP\\");
path q(p / L"wide");  // Works!
path r(p / "narrow"); // Breaks :(

int _tmain(int argc, _TCHAR* argv[])
    path p(L"C:\\TEMP\\");
    path q(p / L"wide");  // Works!
    path r(p / "narrow"); // Works here!

    std::cout << r.string() << std::endl;
	return 0;

P.S. If more info is required I will reply here not by email.


CallStack.txt Download (2.3 KB) - added by john doe <johndoe> 3 years ago.
Full stack trace
paths.cpp Download (493 bytes) - added by john doe <johndoe> 3 years ago.

Change History

Changed 3 years ago by john doe <johndoe>

Full stack trace

Changed 3 years ago by john doe <johndoe>

comment:1 Changed 3 years ago by john doe <johndoe>

  • Keywords filesystem path convert wide/narrow string added

comment:2 Changed 3 years ago by Fraser Hutchison <fraser.hutchison@…>

It appears to be down to an MSVC bug.

The third path constructor calls codecvt(), which calls wchar_t_codecvt_facet(), which returns codecvt_facet. However, codecvt_facet hasn't been initialised at this point.

I believe the Standard requires codecvt_facet to have been initialised before wchar_t_codecvt_facet() since it comes earlier in the same translation unit, hence I think this is an MSVC bug.

I can confirm that there is no problem with this in 1.48.0 - it's moving codecvt_facet from being a static member to a variable in unnamed namespace in 1.49.0 that has caused the issue.

The following slightly simpler program gives the error also:

#include "boost/filesystem/v3/path.hpp"
boost::filesystem::path p("p");
int main() { return 0; }

comment:3 Changed 3 years ago by Nils Gladitz <gladitz@…>

I've got the same problem with Intel 11.1 (+MSVC2005).

comment:4 Changed 3 years ago by anonymous

For what it's worth, you can work around this crash bug by reverting changeset 76303.

This change was implemented to fix issue 6320.

comment:5 Changed 18 months ago by Nils Gladitz <gladitz@…>

The snippet in the description no longer crashes for me in Boost 1.54.0 but now the following (related?) snippet does:

#include <boost/filesystem.hpp>

using namespace boost::filesystem;

class Test
		path p(L"C:\\TEMP\\");
		path r(p / "narrow");

Test test1;
Test test2;

int main()

Add a comment

Modify Ticket

Change Properties
<Author field>
as new

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.