mik*_*rin 8 c++ stack-overflow
这是我在stackoverflow上的第一个问题所以我会尝试具体.我在论坛上搜索了任何相关主题,但没有运气.无论如何这里是:
我正在使用Visual Studio 2005.I遇到堆栈溢出异常:IHR.exe中0x775715de处的未处理异常:0xC00000FD:堆栈溢出.,当试图调试我的项目时.在进入main()函数之前,调用堆栈在ntdll.dll停止时没有帮助.
起初我怀疑它可能是一个编译设置的东西,但是当我将在我的计算机上编译的可执行文件发送到第二台计算机时,它可以正常运行,它只是不能在我的机器上运行.
反过来也是如此,我在第二台计算机上编译了可执行文件,它可以正常运行.但是,当我尝试运行在我的计算机上的第二台计算机上编译的可执行文件时,它无法运行.所有出现的都是一个空白的命令提示符和一条Windows消息,说该程序没有响应.
我使用的是Windows 7 Professional SP1,64位.另一台计算机具有相同的OS版本.由于公司政策,我不能在这里发布任何源代码,但无论如何我认为它与源代码没有任何关系.我怀疑它可能是运行时环境中的问题.感谢任何帮助.谢谢.
以下是调用堆栈中的所有内容:
->ntdll.dll!775715de()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!775715de()
ntdll.dll!7756014e()
Run Code Online (Sandbox Code Playgroud)
感谢@ WhozCraig的建议,我设法在调用堆栈上获得了更有意义的消息.尽管如此仍然难过.
IHR.exe!_mbscmp(const unsigned char*s1 = 0x00fe8c10,const unsigned char*s2 = 0x00fe8c10)第84行+ 0xf字节
IHR.exe!_mbscmp(const unsigned char*s1 = 0x00fe8c10,const unsigned char*s2 = 0x00fe8c10)Line 84 + 0xf字节
IHR.exe!strcmp(const char*_s1 = 0x00fe8c10,const char*_s2 = 0x00fe8c10)行1646 + 0x2b字节
IHR.exe!_mbscmp_l(const unsigned char*s1 = 0x00fe8c10,const unsigned char*s2 = 0x00fe8c10 ,localeinfo_struct*plocinfo = 0x00000000)第58行+ 0xd字节
IHR.exe!_mbscmp(const unsigned char*s1 = 0x00fe8c10,const unsigned char*s2 = 0x00fe8c10)第84行+ 0xf字节
IHR.exe!strcmp(const char*_s1 = 0x00fe8c10,const char*_s2 = 0x00fe8c10)行1646 + 0x2b字节
这里还有一些,直到上面的堆栈
IHR.exe!_mbscmp_l(const unsigned char * s1=0x00fe8c10, const unsigned char * s2=0x00fe8c10, localeinfo_struct * plocinfo=0x00000000) Line 58 + 0xd bytes C++
IHR.exe!_mbscmp(const unsigned char * s1=0x00fe8c10, const unsigned char * s2=0x00fe8c10) Line 84 + 0xf bytes C++
IHR.exe!strcmp(const char * _s1=0x00fe8c10, const char * _s2=0x00fe8c10) Line 1646 + 0x2b bytes
IHR.exe!_setlocale_get_all(threadlocaleinfostruct * ploci=0x002f13a0) Line 1147 + 0x24 bytes
IHR.exe!_setlocale_nolock(threadlocaleinfostruct * ploci=0x002f13a0, int _category=0, const char * _locale=0x00000000) Line 966 + 0x9 bytes C
Run Code Online (Sandbox Code Playgroud)
IHR.exe!setlocale(int _category = 0,const char*_locale = 0x00000000)826行+ 0x1b字节
IHR.exe!std :: _ Locinfo :: _ Locinfo_ctor(std :: _ Locinfo*pLocinfo = 0x0018f8f8,const char*locname = 0x00ea591c )行192 + 0x9字节
IHR.exe!std :: _ Locinfo :: _ Locinfo(const char*_Pch = 0x00ea591c)行78 + 0xd字节
IHR.exe!std :: ctype :: ctype(const short*_Table = 0x00000000,bool _Deletetable = false,unsigned int _Refs = 0)行1740 + 0x10字节
IHR.exe!std :: ctype :: _ Getcat(const std :: locale :: facet**_Ppf = 0x0018fbd8)行1760 + 0x4d字节IHR.exe! std :: use_facet>(const std :: locale&_Loc = {...})第478行+ 0x9字节IHR.exe!std :: basic_ios> :: widen(char _Byte ='')第124行+ 0x34字节
IHR .exe!std :: basic_ios> :: init(std :: basic_streambuf>*_Strbuf = 0x00ff7908,bool _Isstd = false)第135行+ 0xa字节
IHR.exe!std :: basic_ostream> :: basic_ostream>(std :: basic_streambuf >*_Strbuf = 0x00ff7908,bool _Isstd = false)第53行
IHR.exe!std ::`'cout''的动态初始化器()第13行+ 0x16字节IHR.exe!_initterm(void (void)**pfbegin = 0x00e8d10c,void(void)**pfend = 0x00e9dca0)第855行IHR.exe!_cinit(int initFloatingPrecision = 1)第293行+ 0xf字节
IHR.exe!tmainCRTStartup()第310行+ 0x7字节
IHR.exe!mainCRTStartup()第196行
kernel32.dll!@BaseThreadInitThunk @ 12()+ 0x12字节
ntdll.dll!RtlUserThreadStart @ 8()+ 0x27字节
ntdll.dll!_RtlUserThreadStart @ 8()+ 0x1b字节
它不断调用strcmp,mbscmp,mbscmp_l直到它遇到堆栈溢出异常.
更新(2013年4月11日):我找到了引起问题的线路,但我仍然完全不知道为什么会引起这个问题.这是strcmp的用法.
struct Foo
{
char text[4];
bool operator < (const Foo &rhs) const
{
return strcmp(text, rhs.text) < 0;
}
}
Run Code Online (Sandbox Code Playgroud)
当这个strcmp被评论出来时.该计划没有崩溃.处理这样一个问题的任何想法或经验?同样的程序在其他机器上运行正常,但由于这条线路只能在我的机器上崩溃.在整个程序中使用其他strcmp没有问题.谢谢
您可能有全局/静态变量,并且它们在运行 main 之前尝试初始化。实际初始化的顺序可能不是您所期望的,就好像您将它们放在不同的文件中一样,没有办法告诉它们应该按什么顺序创建。
删除这些变量或将它们排列到同一个文件中。
| 归档时间: |
|
| 查看次数: |
2266 次 |
| 最近记录: |