msvcr90.dll!_invalid_parameter_noinfo() Line 125 + 0xc bytes 的排错
2011-04-25 14:15
459 查看
如题。当dump定位到这个地方时,有理由怀疑是下标访问string时越界了。
我们先看Checked Iterators中的例子。
却什么也catch不到,Release版直接crash。通过dump定位到如题的错误。为什么呢?
看一下string::operator[]()的实现。它在Microsoft Visual Studio 9.0/VC/crt/src/xstring中:
而_SCL_SECURE_VALIDATE_RANGE是在/VC/include/yvals.h中定义的:
只要能走到红色位置,就可以和vector一样抛出out_of_range异常,可惜却没有。经跟踪,发现是_SECURE_SCL_THROWS宏在搞鬼。
可是我明明 #define _SECURE_SCL_THROWS 1 了啊。过一段时间有机会再查吧。
我们先看Checked Iterators中的例子。
// compile with: /EHsc #define _SECURE_SCL 1 #define _SECURE_SCL_THROWS 1 #include <vector> #include <iostream> using namespace std; int main() { vector v; v.push_back(67); int i = v[0]; cout << i << endl; try { i = v[1]; } catch (std::out_of_range) { cout << "invalid container access" << endl; } };[/code]
这里vector访问越界,catch会抓到异常。但是如果把vector换成string:
#include <string> int main() { string str = ""; char s; try { s = str[1]; } catch (std::out_of_range) { cout << "invalid container access" << endl; } };
却什么也catch不到,Release版直接crash。通过dump定位到如题的错误。为什么呢?
看一下string::operator[]()的实现。它在Microsoft Visual Studio 9.0/VC/crt/src/xstring中:
reference __CLR_OR_THIS_CALL operator[](size_type _Off) { // subscript mutable sequence #if _HAS_ITERATOR_DEBUGGING // skip debug checks if the container is initizialed with _IGNORE_MYITERLIST if (this->_Myfirstiter != _IGNORE_MYITERLIST) { if (_Mysize < _Off) { _DEBUG_ERROR("string subscript out of range"); _SCL_SECURE_OUT_OF_RANGE; } } #else _SCL_SECURE_VALIDATE_RANGE(_Off <= _Mysize); #endif /* _HAS_ITERATOR_DEBUGGING */ return (_Myptr()[_Off]); }
而_SCL_SECURE_VALIDATE_RANGE是在/VC/include/yvals.h中定义的:
#define _SCL_SECURE_VALIDATE_RANGE(cond) / { / if (!(cond)) / { / _ASSERTE((#cond, 0)); / _SCL_SECURE_OUT_OF_RANGE_NO_ASSERT; / } / __analysis_assume(cond); / }
只要能走到红色位置,就可以和vector一样抛出out_of_range异常,可惜却没有。经跟踪,发现是_SECURE_SCL_THROWS宏在搞鬼。
#if _SECURE_SCL_THROWS #define _SCL_SECURE_INVALID_ARGUMENT_NO_ASSERT _Xinvarg() #define _SCL_SECURE_OUT_OF_RANGE_NO_ASSERT _Xran() #else /* _SECURE_SCL_THROWS */ #define _SCL_SECURE_INVALID_ARGUMENT_NO_ASSERT _SCL_SECURE_INVALID_PARAMETER("invalid argument") #define _SCL_SECURE_OUT_OF_RANGE_NO_ASSERT _SCL_SECURE_INVALID_PARAMETER("out of range")
可是我明明 #define _SECURE_SCL_THROWS 1 了啊。过一段时间有机会再查吧。
相关文章推荐
- msvcr90.dll!_invalid_parameter_noinfo() Line 125 + 0xc bytes 的排错
- msvcr90.dll!_invalid_parameter_noinfo() Line 125 + 0xc bytes 的排错
- 无法定位程序输入点_invalid_parameter_noinfo_noreturn于动态链接库 MSVCR100.dll上
- __invalid_parameter_noinfo vs2005 vc8 问题解决办法
- 无法定位程序输入点 _invalid_parameter_noinfo_noreturn 于动态链接库 MSVCR100.dll 上
- What is invalid parameter noinfo and how do I get rid of it分(如何优化stl迭代器)
- What is invalid parameter noinfo and how do I get rid of it? (转)
- 解决“无法定位程序输入点 _invalid_parameter_noinfo_noreturn于动态链接库MSVCR100.DLL”
- 无法定位程序输入点_invalid_parameter_noinfo_noreturn于动态链接库 MSVCR100.dll上
- __invalid_parameter_noinfo vs2005 vc8 问题解决办法
- "invalid command-line parameter: Files\android" when using eclipse ADT
- 你的Jsp页面有黄×么,有黄色问号么?Multiple annotations found at this line: - Invalid location of tag (form). - No
- 微信支付jsApiParameter::{"return_code":"FAIL","return_msg":"invalid out_trade_no"}
- PDO版本问题 Invalid parameter number: no parameters were bound
- 出现Invalid parameter number: no parameters were boundStack
- 你的Jsp页面有黄×么,有黄色问号么?Multiple annotations found at this line: - Invalid location of tag (form). - No
- 源码剖析Yii错误 Invalid parameter number: no parameters were bound
- PDO版本问题 Invalid parameter number: no parameters were bound
- GDB WHICH HAS NO LINE NUMBER INFO
- 关于Tomcat配置https/SSL报“No Certificate file specified or invalid file format”的问题