首页 文章

main()之前的堆栈溢出异常

提问于
浏览
8

这是我在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()

感谢@ 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

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(voi d(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;
}
}

当这个strcmp被评论出来时 . 该计划没有崩溃 . 处理这样一个问题的任何想法或经验?同样的程序在其他机器上运行正常,但由于这条线路只能在我的机器上崩溃 . 在整个程序中使用其他strcmp没有问题 . 谢谢

1 回答

  • 2

    您可能有全局/静态变量,并且在运行main之前它们正在尝试初始化 . 实际初始化的顺序可能不是您所期望的,就好像您将它们放在不同的文件中一样,没有办法告诉它们应该以何种顺序创建 .

    删除这些变量或将它们排列到同一个文件中 .

相关问题