简体   繁体   中英

Weird exception when debugging in visual studio 2010 c++

I am experiencing this error when I try to debug my program. it seems that it cannot even take in the argument I pass to main function:

int main(int argc, char* argv[]){
    if(argc!=4) std::cout<<wrong input";
    else{
       //other codes
    }
    return 0;
}

I put my breakpoint on the first line (main function line) and it gives me the following error:

'MESH.exe': Loaded 'C:\Users\Avan\Documents\NUS\Yr3_Sem2\CS3242\MESH\Debug\MESH.exe',       Symbols loaded.
'MESH.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
'MESH.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
'MESH.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
'MESH.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded (source information stripped).
'MESH.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded (source information stripped).
First-chance exception at 0x00318c67 in MESH.exe: 0xC00000FD: Stack overflow.
Unhandled exception at 0x00318c67 in MESH.exe: 0xC00000FD: Stack overflow.
First-chance exception at 0x00318c67 in MESH.exe: 0xC0000005: Access violation reading     location 0x003a0000.
Unhandled exception at 0x00318c67 in MESH.exe: 0xC0000005: Access violation reading location 0x003a0000.
The program '[4800] MESH.exe: Native' has exited with code -1073741819 (0xc0000005).

So I presume the error comes from when I passing down the input. I have set the command line input argument in the project->properties->debugging

the error keep pointing to a chkstk.asm file which I have no idea what is it.

; Find next lower page and probe
cs20:
    sub     eax, _PAGESIZE_         ; decrease by PAGESIZE
    **test    dword ptr [eax],eax     ; probe page.**
    jmp     short cs10

_chkstk endp

    end

The pointer keep pointing to the line indicated above with the **. Can anyone tell me what could have gone wrong?

Well, given it's complaining about a stack overflow, the first thing I'd be looking at is if you're trying to allocate a lot of stuff on the stack.

For example, if your //other codes contains something like:

int bigarray[9999999999];

then that would be a likely culprit.

I wouldn't be too worried about the fact that the error is coming from chkstk.asm , that's almost certainly some defensive code which is checking to see if you've blown out the stack (hence chkstk for check stack ) and generating the first-chance exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM