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

时间:2013-03-15 06:40:26

标签: c++ stack-overflow

这是我在stackoverflow上的第一个问题,所以我会尝试具体。我在论坛上搜索了任何相关主题,但没有运气。无论如何这里是:

我正在使用Visual Studio 2005.I遇到堆栈溢出异常:IHR.exe中0x775715de处的未处理异常:0xC00000FD:堆栈溢出。 ,当试图调试我的项目时。在进入main()函数之前,调用堆栈在ntdll.dll停止时没有帮助。

起初我怀疑它可能是一个编译设置的东西,但当我将在我的计算机上编译的可执行文件发送到第二台计算机时,它可以正常运行,它只是不能在我的机器上运行。

反之亦然,我在第二台计算机上编译了可执行文件,它可以正常运行。但是,当我尝试运行在我的计算机上的第二台计算机上编译的可执行文件时,它无法运行。所有出现的都是一个空白的命令提示符和一条Windows消息,说该程序没有响应。

我正在使用64位的Windows 7 Professional SP1。另一台计算机具有相同的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)第84行+ 0xf字节
      IHR.exe!strcmp(const char * _s1 = 0x00fe8c10,const char * _s2 = 0x00fe8c10)1646行+ 0x2b字节
      IHR.exe!_mbscmp_l(常量无符号字符* S1 = 0x00fe8c10,常量无符号字符* S2 = 0x00fe8c10,localeinfo_struct * plocinfo = 00000000)线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(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 bytes
      ntdll.dll!
RtlUserThreadStart @ 8()+ 0x27字节
      ntdll.dll!
_RtlUserThreadStart @ 8()+ 0x1b bytes

它不断调用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 个答案:

答案 0 :(得分:2)

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

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

相关问题