Ticket #6638 (assigned Bugs)

Opened 4 years ago

Last modified 3 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.59.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> 4 years ago.
Full stack trace
paths.cpp Download (493 bytes) - added by john doe <johndoe> 4 years ago.

Change History

Changed 4 years ago by john doe <johndoe>

Full stack trace

Changed 4 years ago by john doe <johndoe>

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

  • Keywords filesystem path convert wide/narrow string added

comment:2 Changed 4 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 4 years ago by Nils Gladitz <gladitz@…>

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

comment:4 Changed 4 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 2 years 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()

comment:6 Changed 6 months ago by Andrei Ortolan - andrei-fsnt@…

Me too in boost_1_57_0_32_b_vs10


bool CheckCreateDir?(std::string path){


if (boost::filesystem::exists(path))

return true;

} catch (const boost::filesystem::filesystem_error& ex){

std::cout << "\n EX " << ex.what(); return false;


bool res; try{

res = boost::filesystem::create_directories(path);

} catch (...){

return false;

} return res;


comment:7 Changed 3 months ago by bemandawes

  • Status changed from new to assigned
  • Version changed from Boost 1.49.0 to Boost 1.59.0

The original problem and the example from Fraser Hutchison appear to have been corrected some time ago.

The code supplied by Andrei Ortolan works fine for me, once the missing backslashes are added.

The code supplied by Nils Gladitz (Test test1; Test test2;) fails for me on static builds. It is not failing for me for shared builds. Tests run only on Windows.

There is a simple workaround; add path p("narrow"; before the two Test variables, and it works fine.

I'd like to fix the underlying problem, but have not come up with anything workable. So it will stay open for a while longer.




Add a comment

Modify Ticket

Change Properties
<Author field>
as assigned

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

Note: See TracTickets for help on using tickets.