【问题标题】:boost::regex behaving differently on debug and release buildsboost::regex 在调试和发布版本上表现不同
【发布时间】:2011-04-09 22:22:32
【问题描述】:
boost::regex re("^\\s*([_\\w\\.]+)\\s*=\\s*([^\\s]+)$");
if(re.empty()){
  std::cout<<"How is this possible?"<<std::endl;
}

该行打印在我的发布版本中! (调试版本很好) 使用 MSVC 2008 (vc 9.0)

DEBUG 的编译器选项:

/Od /I "C:\Program Files\boost\boost_1_44_0" /I "C:\gtest-1.5.0\include" /I "include" /I "include\EMP" /I "dependencies\EMP\include" /I "dependencies\APR\apr-1.3.3\include" /I "dependencies\solclient_5.0.0.22\include" /I "dependencies\SS66\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "EMP_WIN_X86_32" /D "_iso_stdcpp_" /D "_CRT_SECURE_NO_DEPRECATE" /D "_SECURE_SCL=0" /D "_EMPAPI_STATIC_BUILD" /D "_EMPAPI_STATIC_LINK" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /fp:fast /Fo"Debug\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt

RELEASE 的编译器选项:

/O2 /Oi /GL /I "C:\Program Files\boost\boost_1_44_0" /I "C:\gtest-1.5.0\include" /I "include" /I "include\EMP" /I "dependencies\EMP\include" /I "dependencies\APR\apr-1.3.3\include" /I "dependencies\solclient_5.0.0.22\include" /I "dependencies\SS66\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "EMP_WIN_X86_32" /D "_iso_stdcpp_" /D "_CRT_SECURE_NO_DEPRECATE" /D "_SECURE_SCL=0" /D "_EMPAPI_STATIC_BUILD" /D "_EMPAPI_STATIC_LINK" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Gy /fp:fast /Fo"Release\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt

DEBUG 的链接器选项:

/OUT:"C:\WorkFlow\cpp_client_library\Debug\cpp_client_library.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\APR\apr-1.3.3\Release" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\EMP\lib\win32_vc80" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\solclient_5.0.0.22\lib" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\SS66\lib\i86_w32" /LIBPATH:"C:\Program Files\boost\boost_1_44_0\stage\lib" /LIBPATH:"C:\gtest-1.5.0\msvc\gtest\Debug" /MANIFEST /MANIFESTFILE:"Debug\cpp_client_library.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\WorkFlow\cpp_client_library\Debug\cpp_client_library.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT emp.lib libsolclient.lib tipc.lib tutil.lib gtestd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

RELEASE 的链接器选项:

/OUT:"C:\WorkFlow\cpp_client_library\Release\cpp_client_library.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\APR\apr-1.3.3\Release" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\EMP\lib\win32_vc80" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\solclient_5.0.0.22\lib" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\SS66\lib\i86_w32" /LIBPATH:"C:\Program Files\boost\boost_1_44_0\stage\lib" /LIBPATH:"C:\gtest-1.5.0\msvc\gtest\Release" /MANIFEST /MANIFESTFILE:"Release\cpp_client_library.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\WorkFlow\cpp_client_library\Release\cpp_client_library.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT emp.lib libsolclient.lib tipc.lib tutil.lib gtest.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

【问题讨论】:

  • 访问冲突有同样的问题
  • @JXITC,您是否查看了 svn.boost.org/trac/boost/ticket/768 上给出的解释?引用-“经过对相同问题的长时间调查(实际使用正则表达式时程序退出时崩溃),我发现问题是由于混淆了 VC++ 2005 版本引起的:该库是用 VC++ 2005 编译的,没有 SP1,程序是用带有 SP1 的 VC++ 2005。当我使用带有 SP1 的 VC++ 2005 编译库时,问题就消失了。"

标签: regex boost debugging release


【解决方案1】:

我转而使用 Visual Studio 2005,问题消失了,但我现在在应用程序结束时遇到异常:

myApp.exe 中 0x0042d935 处未处理的异常:0xC0000005:访问冲突读取位置 0xe06d7390。

调用栈是

kernel32.dll!7c812afb()
[以下帧可能不正确和/或丢失,没有为 kernel32.dll 加载符号]
kernel32.dll!7c812afb()
msvcp80.dll!7c421201()
msvcp80.dll!7c42394d()
msvcp80.dll!7c423958()
msvcr80.dll!78158e89()
myApp.exe!std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::erase(std::_Tree,std::allocator > ,std::less,std::allocator,std::allocator > > >,0> >::iterator _Where={...}) 第 759 行
msvcr80.dll!78134c39()
myApp.exe!std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::erase(std::_Tree,std::allocator > ,std::less,std::allocator,std::allocator > >,0> >::iterator _First={...}, std::_Tree,std::allocator >,std::less,std ::allocator,std::allocator > > >,0> >::iterator _Last={...}) 第 926 行 + 0x4f 个字节 myApp.exe!boost::re_detail::w32_regex_traits_implementation::~w32_regex_traits_implementation() + 0xc0 字节
myApp.exe!boost::detail::sp_counted_impl_p >::dispose() + 0xf 字节
myApp.exe!std::list const >,unsigned long const *>,std::allocator const >,unsigned long const *> > >::clear() + 0x3e 字节 myApp.exe!boost::object_cache >::data::~data() + 0x6b 字节 msvcr80.dll!781319d8()
msvcr80.dll!78131a4b()
myApp.exe!__tmainCRTStartup() 第 603 行 kernel32.dll!7c817077()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    相关资源
    最近更新 更多