You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MB-45378: Avoid crash with boost::fs global object
On MSVC 2017 if platform is linked statically, we see a crash in
~EpBucketImpl when removing the dbPath temp directory:
msvcp140.dll!_guard_dispatch_icall_nop() Line 55 Unknown
msvcp140.dll!std::codecvt<unsigned short,char,_Mbstatet>::in(_Mbstatet & _State, const char * _First1, const char * _Last1, const char * & _Mid1, unsigned short * _First2, unsigned short * _Last2, unsigned short * & _Mid2) Line 728 C++
memcached_testapp.exe!boost::filesystem::path_traits::convert(wchar_t const *,wchar_t const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<wchar_t,char,struct _Mbstatet> const &) C++
memcached_testapp.exe!boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,struct _Mbstatet> const &) C++
> memcached_testapp.exe!boost::filesystem::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) Line 1006 C++
memcached_testapp.exe!boost::filesystem::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) Line 257 C++
memcached_testapp.exe!boost::filesystem::path::path<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & source, void * __formal) Line 168 C++
memcached_testapp.exe!cb::io::makeExtendedLengthPath(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & path) Line 46 C++
memcached_testapp.exe!cb::io::rmrf(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & path) Line 221 C++
memcached_testapp.exe!EpBucketImpl::~EpBucketImpl() Line 214 C++
[External Code]
memcached_testapp.exe!McdEnvironment::~McdEnvironment() Line 388 C++
[External Code]
memcached_testapp.exe!testing::internal::Delete<testing::Environment>(testing::Environment * x) Line 342 C++
[External Code]
memcached_testapp.exe!testing::internal::ForEach<std::vector<testing::Environment *,std::allocator<testing::Environment *> >,void (__cdecl*)(testing::Environment *)>(const std::vector<testing::Environment *,std::allocator<testing::Environment *> > & c, void(*)(testing::Environment *) functor) Line 295 C++
memcached_testapp.exe!testing::internal::UnitTestImpl::~UnitTestImpl() Line 5033 C++
[External Code]
memcached_testapp.exe!testing::UnitTest::~UnitTest() Line 4979 C++
[External Code]
This appears to be a known issue[1] with boost::filesystem, due to it
using a static global for locale conversion - making any calls to
boost::filesystem::path to/from string after this locale object has been
deleted can crash the program. This is happening inside cb::io::rmrf
when it manipulates paths to delete all files under the given dbPath.
Avoid this issue by changing dbPath to boost::fs::path - meaning
we already have a object which has performed locale conversion at
shutdown, then replacing the call to cb::io::rmrf with
boost::fs::remove_all(), which doesn't perform any additional locale
manipulation.
[1]: https://www.boost.org/doc/libs/1_76_0/libs/log/doc/html/log/rationale/why_crash_on_term.html
Change-Id: I1783e669392b9abedabfe59d0249e429a51fe826
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/152073
Tested-by: Trond Norbye <[email protected]>
Reviewed-by: Trond Norbye <[email protected]>
0 commit comments