boost = 1.54 IDE = Visual Studio 2005 / 2012 OS = Windows 7 Hi, I have a 32-bit application that I am upgrading from Visual Studio 2005 to 2012. If I place the following code at the beginning of the application: { //test 1 boost::filesystem::path blahPath; } { //test 2 boost::filesystem::path blahPath = _T( "C:\\ProgramData\\blah" ); } { //test 3 boost::filesystem::path blahPath; std::wstring text = _T( "C:\\ProgramData\\blah" ); blahPath = text; } then it works fine in Visual Studio 2005, however test 3 crashes in Visual Studio 2012 with: --------------------------- Microsoft Visual C++ Runtime Library --------------------------- Debug Assertion Failed! File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp Line: 52 Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) and this callstack: msvcr110d.dll!operator delete(void * pUserData) Line 52 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::allocator<wchar_t>::deallocate(wchar_t * _Ptr, unsigned int __formal) Line 586 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::_Wrap_alloc<std::allocator<wchar_t>
::deallocate(wchar_t * _Ptr, unsigned int _Count) Line 888 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> ::_Tidy(bool _Built, unsigned int _Newsize) Line 2265 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> ::~basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> () Line 965 C++ boost_filesystem-vc110-mt-gd-1_54.dll!boost::filesystem::path::~path() C++ blah.exe!CPlanarApp::InitInstance() Line 152 C++ mfc110ud.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 37 C++ blah.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 26 C++ blah.exe!__tmainCRTStartup() Line 528 C blah.exe!wWinMainCRTStartup() Line 377 C kernel32.dll!75ce33aa() Unknown [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!76f09ef2() Unknown ntdll.dll!76f09ec5() Unknown
The boost::filesystem::path destructor is being called and is causing a crash. I do not understand how the first two tests can pass yet there is a problem with the third test. Is there something that I am doing wrong here or does anyone have any advice please? Thanks, Patrick
Bump. Does anyone have any idea why this code is causing a crash please? On 2 September 2013 13:15, Patrick Steele <steele.patrick@gmail.com> wrote:
boost = 1.54 IDE = Visual Studio 2005 / 2012 OS = Windows 7
Hi, I have a 32-bit application that I am upgrading from Visual Studio 2005 to 2012. If I place the following code at the beginning of the application:
{ //test 1 boost::filesystem::path blahPath; }
{ //test 2 boost::filesystem::path blahPath = _T( "C:\\ProgramData\\blah" ); }
{ //test 3 boost::filesystem::path blahPath; std::wstring text = _T( "C:\\ProgramData\\blah" ); blahPath = text; }
then it works fine in Visual Studio 2005, however test 3 crashes in Visual Studio 2012 with:
--------------------------- Microsoft Visual C++ Runtime Library --------------------------- Debug Assertion Failed!
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp Line: 52
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
and this callstack:
msvcr110d.dll!operator delete(void * pUserData) Line 52 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::allocator<wchar_t>::deallocate(wchar_t * _Ptr, unsigned int __formal) Line 586 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::_Wrap_alloc<std::allocator<wchar_t>
::deallocate(wchar_t * _Ptr, unsigned int _Count) Line 888 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> ::_Tidy(bool _Built, unsigned int _Newsize) Line 2265 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> ::~basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> () Line 965 C++ boost_filesystem-vc110-mt-gd-1_54.dll!boost::filesystem::path::~path() C++ blah.exe!CPlanarApp::InitInstance() Line 152 C++ mfc110ud.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 37 C++ blah.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 26 C++ blah.exe!__tmainCRTStartup() Line 528 C blah.exe!wWinMainCRTStartup() Line 377 C kernel32.dll!75ce33aa() Unknown [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!76f09ef2() Unknown ntdll.dll!76f09ec5() Unknown
The boost::filesystem::path destructor is being called and is causing a crash. I do not understand how the first two tests can pass yet there is a problem with the third test. Is there something that I am doing wrong here or does anyone have any advice please? Thanks, Patrick
On 4.9.2013 10:45, Patrick Steele wrote:
Bump. Does anyone have any idea why this code is causing a crash please? msvcr110d.dll!operator delete(void * pUserData) Line 52 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::allocator<wchar_t>::deallocate(wchar_t * _Ptr, unsigned int __formal) Line 586 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::_Wrap_alloc<std::allocator<wchar_t> >::deallocate(wchar_t * _Ptr, unsigned int _Count) Line 888 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::_Tidy(bool _Built, unsigned int _Newsize) Line 2265 C++ boost_filesystem-vc110-mt-gd-1_54.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::~basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >() Line 965 C++
Hi, just guessing, but make sure you're using binary compatible versions of built Boost libraries and your application. It could be that you're building your app eg. with _SECURE_SCL=0 (or any flag that modifies runtime behaviour) but Boost with _SECURE_SCL=1 (which is the default for debug builds). Or vice versa. That would explain why the crash occurs in the string destructor; you're constucting it without additional debug checking (= in your app), but when destructor is called (= in filesystem), it expects the additional information/members/data to be there (but it isn't) that it tries to tidy. -- Pekka
Hi Pekka, thanks for the help. I tried using _SECURE_SCL=1 and _SECURE_SCL=0 but still got the same crash. I see that other variables currently being used in the debug build of my application are: _SCL_SECURE_NO_DEPRECATE=1 _ATL_SECURE_NO_DEPRECATE=1 _AFX_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_DEPRECATE=1 STRSAFE_NO_DEPRECATE=1 _CRT_SECURE_NO_WARNINGS Do you think that any of these might be the problem? Thanks, Patrick On 4 September 2013 09:04, Pekka Seppänen < pekka.seppanen@capricodesystems.com> wrote:
On 4.9.2013 10:45, Patrick Steele wrote:
Bump. Does anyone have any idea why this code is causing a crash please? msvcr110d.dll!operator delete(void * pUserData) Line 52 C++ boost_filesystem-vc110-mt-gd-**1_54.dll!std::allocator<wchar_** t>::deallocate(wchar_t * _Ptr, unsigned int __formal) Line 586 C++ boost_filesystem-vc110-mt-gd-**1_54.dll!std::_Wrap_alloc<std:** :allocator<wchar_t> >::deallocate(wchar_t * _Ptr, unsigned int _Count) Line 888 C++ boost_filesystem-vc110-mt-gd-**1_54.dll!std::basic_string<** wchar_t,std::char_traits<**wchar_t>,std::allocator<wchar_**t> >::_Tidy(bool _Built, unsigned int _Newsize) Line 2265 C++ boost_filesystem-vc110-mt-gd-**1_54.dll!std::basic_string<** wchar_t,std::char_traits<**wchar_t>,std::allocator<wchar_**t> >::~basic_string<wchar_t,std::**char_traits<wchar_t>,std::**allocator<wchar_t>
() Line 965 C++
Hi,
just guessing, but make sure you're using binary compatible versions of built Boost libraries and your application.
It could be that you're building your app eg. with _SECURE_SCL=0 (or any flag that modifies runtime behaviour) but Boost with _SECURE_SCL=1 (which is the default for debug builds). Or vice versa.
That would explain why the crash occurs in the string destructor; you're constucting it without additional debug checking (= in your app), but when destructor is called (= in filesystem), it expects the additional information/members/data to be there (but it isn't) that it tries to tidy.
-- Pekka ______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users<http://lists.boost.org/mailman/listinfo.cgi/boost-users>
On 4.9.2013 14:43, Patrick Steele wrote:
Hi Pekka, thanks for the help. I tried using _SECURE_SCL=1 and _SECURE_SCL=0 but still got the same crash. I see that other variables currently being used in the debug build of my application are:
<snip> Well, I'd first try to compile Boost (debug variant) with those very same defines set. Either pass those directly to B2.EXE (define=FLAG=value) or look at BOOST_USER_CONFIG. If that does not work, then I'd try to ditch all those defines alltogether (just make sure everything is as default as it gets). At least with some debug runtime versions it was impossible to have a dynamically linked runtime and define custom runtime related options at the same time; It would always lead to crashes like the one you're encountering. It could be, that this limitation still exists and if you'd like to disable some debug features you'll have to static link everything. Of course, this is usually impossible and impractical. Then, your only option is to use release runtime without any optimization options set. That way you'll keep your app both usable (what comes to speed) and somewhat debuggable. It's not that you're able to catch all errors with debug runtime anyway. -- Pekka
I did statically link years ago but then, as you said, new releases of some libraries prevented me from doing this anymore and I needed to link dynamically. I managed to remove the extra preprocessor definitions from my application. I then modified the code to look like test 2 above which works and allows me to continue. Test 3 still causes a crash but I cannot see a reason for it :| On 4 September 2013 13:32, Pekka Seppänen < pekka.seppanen@capricodesystems.com> wrote:
On 4.9.2013 14:43, Patrick Steele wrote:
Hi Pekka, thanks for the help. I tried using _SECURE_SCL=1 and _SECURE_SCL=0 but still got the same crash. I see that other variables currently being used in the debug build of my application are:
<snip>
Well, I'd first try to compile Boost (debug variant) with those very same defines set. Either pass those directly to B2.EXE (define=FLAG=value) or look at BOOST_USER_CONFIG.
If that does not work, then I'd try to ditch all those defines alltogether (just make sure everything is as default as it gets). At least with some debug runtime versions it was impossible to have a dynamically linked runtime and define custom runtime related options at the same time; It would always lead to crashes like the one you're encountering.
It could be, that this limitation still exists and if you'd like to disable some debug features you'll have to static link everything. Of course, this is usually impossible and impractical. Then, your only option is to use release runtime without any optimization options set. That way you'll keep your app both usable (what comes to speed) and somewhat debuggable. It's not that you're able to catch all errors with debug runtime anyway.
-- Pekka
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users<http://lists.boost.org/mailman/listinfo.cgi/boost-users>
On 9/5/2013 10:27 AM, Patrick Steele wrote:
I did statically link years ago but then, as you said, new releases of some libraries prevented me from doing this anymore and I needed to link dynamically. I managed to remove the extra preprocessor definitions from my application. I then modified the code to look like test 2 above which works and allows me to continue. Test 3 still causes a crash but I cannot see a reason for it :|
Is it possible you are building with MBCS rather than Unicode ?
Hi Edward, all projects of my application are compiled using unicode. Boost itself was compiled for Visual Studio 2012 as follows: b2.exe --toolset=msvc-11.0 threading=multi link=shared runtime-link=shared variant=debug b2.exe --toolset=msvc-11.0 threading=multi link=shared runtime-link=shared variant=release Other than changing the msvc version number due to upgrading from Visual Studio 2005 to 2012, I have used these same compile options for years. Is there any further information that I can provide that might help diagnose the problem? Thanks, Patrick On 6 September 2013 00:59, Edward Diener <eldiener@tropicsoft.com> wrote:
On 9/5/2013 10:27 AM, Patrick Steele wrote:
I did statically link years ago but then, as you said, new releases of some libraries prevented me from doing this anymore and I needed to link dynamically. I managed to remove the extra preprocessor definitions from my application. I then modified the code to look like test 2 above which works and allows me to continue. Test 3 still causes a crash but I cannot see a reason for it :|
Is it possible you are building with MBCS rather than Unicode ?
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users<http://lists.boost.org/mailman/listinfo.cgi/boost-users>
participants (3)
-
Edward Diener
-
Patrick Steele
-
Pekka Seppänen