title: Stack overflow exception before main()
body: <p>this is my first question here on stackoverflow so I'll try to be specific. I searched the forums for any related topic but no luck. Anyway here goes:</p>
  
  <p>I'm using Visual Studio 2005.I encountered a stack overflow exception :Unhandled exception at 0x775715de in IHR.exe: 0xC00000FD: Stack overflow. ,when attempting to debug my project. The call stack does not help as it stops at ntdll.dll, before even entering the main() function. </p>
  
  <p>At first I suspected that it may be a compilation settings thing, but when I sent the executable compiled on my computer to a second computer, it could run fine, it just won't run on my machine. </p>
  
  <p>The same happens in reverse, I compiled the executable on the second computer, it could run fine on that. But when I tried to run the executable that was compiled on the second computer on my computer, it couldn't run. All that appeared was a blank command prompt and a windows message saying the program was not responding. </p>
  
  <p>I'm using Windows 7 Professional SP1, 64 bit. The other computer has the same OS version. Due to company policy, I can't post any source code here, but anyway I don't think it has anything to do with the source code. I suspect it may be a problem in the runtime environment. Appreciate any help. Thanks.</p>
  
  <p>Here's all there is on the call stack:</p>
  
  <pre><code>-&gt;ntdll.dll!775715de()  
  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
  ntdll.dll!775715de()    
  ntdll.dll!7756014e()
  </code></pre>
  
  <p>Thanks to @WhozCraig's  suggestion, I have managed to get a more meaningful message on the call stack. Still stumped though.</p>
  
  <blockquote>
    <p>IHR.exe!_mbscmp(const unsigned char * s1=0x00fe8c10, const unsigned char * s2=0x00fe8c10)  Line 84 + 0xf bytes<br>
        IHR.exe!_mbscmp(const unsigned char * s1=0x00fe8c10, const unsigned char * s2=0x00fe8c10)  Line 84 + 0xf bytes<br>
        IHR.exe!strcmp(const char * _s1=0x00fe8c10, const char * _s2=0x00fe8c10)  Line 1646 + 0x2b bytes<br>
        IHR.exe!_mbscmp_l(const unsigned char * s1=0x00fe8c10, const unsigned char * s2=0x00fe8c10, localeinfo_struct * plocinfo=0x00000000)  Line 58 + 0xd bytes<br>
        IHR.exe!_mbscmp(const unsigned char * s1=0x00fe8c10, const unsigned char * s2=0x00fe8c10)  Line 84 + 0xf bytes<br>
        IHR.exe!strcmp(const char * _s1=0x00fe8c10, const char * _s2=0x00fe8c10)  Line 1646 + 0x2b bytes</p>
  </blockquote>
  
  <p>here's some more, leading up to the stack above</p>
  
  <pre><code>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
  </code></pre>
  
  <blockquote>
    <p>IHR.exe!setlocale(int _category=0, const char * _locale=0x00000000)  Line 826 + 0x1b bytes<br>
        IHR.exe!std::_Locinfo::_Locinfo_ctor(std::_Locinfo * pLocinfo=0x0018f8f8, const char * locname=0x00ea591c)  Line 192 + 0x9 bytes<br>
        IHR.exe!std::_Locinfo::_Locinfo(const char * _Pch=0x00ea591c)  Line 78 + 0xd bytes<br>
        IHR.exe!std::ctype::ctype(const short * _Table=0x00000000, bool _Deletetable=false, unsigned int _Refs=0)  Line 1740 + 0x10 bytes<br>
        IHR.exe!std::ctype::_Getcat(const std::locale::facet * * _Ppf=0x0018fbd8)  Line 1760 + 0x4d bytes 
        IHR.exe!std::use_facet >(const std::locale &amp; _Loc={...})  Line 478 + 0x9 bytes 
        IHR.exe!std::basic_ios >::widen(char _Byte=' ')  Line 124 + 0x34 bytes<br>
        IHR.exe!std::basic_ios >::init(std::basic_streambuf > * _Strbuf=0x00ff7908, bool _Isstd=false)  Line 135 + 0xa bytes<br>
        IHR.exe!std::basic_ostream >::basic_ostream >(std::basic_streambuf > * _Strbuf=0x00ff7908, bool _Isstd=false)  Line 53<br>
        IHR.exe!std::`dynamic initializer for 'cout''()  Line 13 + 0x16 bytes
        IHR.exe!_initterm(void (void)* * pfbegin=0x00e8d10c, void (void)* * pfend=0x00e9dca0)  Line 855 
        IHR.exe!_cinit(int initFloatingPrecision=1)  Line 293 + 0xf bytes<br>
        IHR.exe!<strong>tmainCRTStartup()  Line 310 + 0x7 bytes<br>
        IHR.exe!mainCRTStartup()  Line 196<br>
        kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes<br>
        ntdll.dll!</strong><em>RtlUserThreadStart@8()  + 0x27 bytes<br>
        ntdll.dll!</em>_RtlUserThreadStart@8()  + 0x1b bytes    </p>
  </blockquote>
  
  <p>It keeps repeatedly calling strcmp, mbscmp, mbscmp_l until it hits a stack overflow exception. </p>
  
  <p>Update(11 April 2013): I've found the line that causes the problem, but am still totally clueless on why it's causing it. It's the usage of a strcmp. </p>
  
  <pre><code>struct Foo
  {
      char text[4];
      bool operator &lt; (const Foo &amp;rhs) const
  {
      return strcmp(text, rhs.text) &lt; 0;
  }
  }
  </code></pre>
  
  <p>When this strcmp was commented out. The program did not crash. Any ideas or experience with dealing with such a problem? The same program still runs fine on other machines, but only crashes on my machine due to this line. other strcmp is used throughout the program with no issue. Thanks</p>