Opened 11 years ago
Closed 11 years ago
#6690 closed Bugs (fixed)
access violation using global path object
Reported by: | Claudio Bley | Owned by: | Beman Dawes |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.49.0 | Severity: | Regression |
Keywords: | Cc: |
Description
I think this is an instance of "static initialization order fiasco".
The following code crashes with "Access violation reading location 0x00000000".
#include <boost/filesystem.hpp> #include <iostream> const boost::filesystem::path p("test"); int main(int argc, char *argv[]) { std::cout << p << std::endl; }
This is caused by codecvt_facet
not being initialised on its first use. Call Stack:
fspath.exe!std::codecvt<wchar_t,char,int>::in(int & _State, const char * _First1, const char * _Last1, const char * & _Mid1, wchar_t * _First2, wchar_t * _Last2, wchar_t * & _Mid2) Line 1521 + 0x1f bytes C++ fspath.exe!`anonymous namespace'::convert_aux(const char * from, const char * from_end, wchar_t * to, wchar_t * to_end, std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & target, const std::codecvt<wchar_t,char,int> & cvt) Line 84 + 0x24 bytes C++ fspath.exe!boost::filesystem3::path_traits::convert(const char * from, const char * from_end, std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & to, const std::codecvt<wchar_t,char,int> & cvt) Line 165 + 0x20 bytes C++ fspath.exe!boost::filesystem3::path_traits::dispatch<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > >(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & c, std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & to, const std::codecvt<wchar_t,char,int> & cvt) Line 174 + 0x60 bytes C++ fspath.exe!boost::filesystem3::path::path<char const [5]>(const char [5]& source, void * __formal) Line 135 + 0x23 bytes C++
this == 0x00000000
Compiled with cl /EHsc /DEBUG /Zi /D _DEBUG /MTd /I%localappdata%\boost\boost_1_49 fspath.cpp /link /libpath:%localappdata%\boost\boost_1_49\lib
.
- Claudio
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Status: | new → assigned |
---|
comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
After some hunting:
I suppose that an assertion checking the pointer in path::wchar_t_codecvt_facet() implementation would be helpful for tests.
I don't have time to go farther, but my understanding is that either:
For this last point, I think that it would be good to check that the compiled code is not the "all posix" one:
Assuming you add an assertion in the function implementation, setting this variable to null would then be very helpful in tests too.
I think I'll have to switch back to the previous boost version for now but I hope you can fin the problem.