Modify

Ticket #6638 (new Bugs)

Opened 2 years ago

Last modified 7 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:

Description

path_traits.cpp

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.

Attachments

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

Change History

Changed 2 years ago by john doe <johndoe>

Full stack trace

Changed 2 years ago by john doe <johndoe>

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

  • Keywords filesystem path convert wide/narrow string added

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

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

comment:4 Changed 2 years ago by anonymous

For what it's worth, you can work around this crash bug by reverting changeset 76303.  https://svn.boost.org/trac/boost/changeset/76303/trunk/libs/filesystem/v3/src/path.

This change was implemented to fix issue 6320.  https://svn.boost.org/trac/boost/ticket/6320

comment:5 Changed 7 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
{
public:
	~Test()
	{
		path p(L"C:\\TEMP\\");
		path r(p / "narrow");
	}
};

Test test1;
Test test2;

int main()
{
	
}
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
Author


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

 
Note: See TracTickets for help on using tickets.