开发者

win7 + vc7.1 + mfc = stackoverflow

开发者 https://www.devze.com 2022-12-27 18:07 出处:网络
I\'ve moved my vc7.1 project from WInXP to Win7. After rebuilding i got stackoverflow error in function _malloc_dbg when i start the program.

I've moved my vc7.1 project from WInXP to Win7. After rebuilding i got stackoverflow error in function _malloc_dbg when i start the program.

"Unhandled exception at 0x0051bf0f in XXX.exe: 0xC00000FD: Stack overflow."

----------------------
Call stack:
> msvcr71d.dll!_malloc_dbg(unsigned int nSize=140, int nBlockUse=2, const char * szFileName=0x10267784, int nLine=163)

  msvcr71d.dll!_calloc_dbg(unsigned int nNum=1, unsigned int nSize=140, int nBlockUse=2, const char * szFileName=0x10267784, int nLine=163)

  msvcr71d.dll!_mtinit()

  msvcr71d.dll!_CRTDLL_INIT(void * hDllHandle=0x10200000, unsigned long dwReason=1, void * lpre开发者_如何学JAVAserved=0x0018fd24)

----------------------

I tried to set up different stacksizes in project options (from 10 to 100 mbytes), in all cases i got this error.

How can i fix this?


Warnings like "conversion from 'int' to 'void ' of greater size" and "conversion from 'size_t' to 'int', possible loss of data" almost certainly mean you're accidentally compiling your application as 64-bit. What they're trying to say is that the size of int (typically 32 bits) and size_t or void are differing. In a 32-bit compile size_t would usually be the same size as int while in 64-bit it may be 64 bits. The same applies with pointer types like void*.

I would first double check that your application is in fact building in 32-bit mode. Is there something like unix "file" you can run to check the executable format?

Once that's checked I can think of two possible reasons for stack overflow: Since the code you show is in malloc, perhaps you have a latent heap memory bug that's just show up now in the new environment. If it's trashing a portion of the stack it could look like it overflowed.

Alternately you could be inadvertently infinitely recursing (again, possibly due to a subtle change in build environment) and actually using up all your stack. Infinite recursion can use up stack space remarkably fast.

0

精彩评论

暂无评论...
验证码 换一张
取 消