0

After installing Visual Studio 2013 Express on my Windows 7 64-bit PC, I tested the following simple Hello World C++ program:

1  #include <iostream>
2  using namespace std;
3
4  int main() {
5      cout << "Hello World" << endl;
6      return 0;
7  }

When I run this code in normal execution (using ctr+F5), the programs runs fine. However, when I run it with the debugger (using F5 only), I get the following message box that appears :

"First-chance exception at 0x778412C7 in ConsoleApplication1.exe: 0xC0000008: An invalid handle was specified.

If there is a handler for this exception, the program may be safely continued."

I press continue and then another message box appear saying :

Unhandled exception at 0x778412C7 in ConsoleApplication1.exe: 0xC0000008: An invalid handle was specified.

If there is a handler for this exception, the program may be safely continued.

I press continue again and the console output is the following :

'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\212426625\Desktop\ConsoleApplication1\Debug\ConsoleApplication1.exe'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\DgApi.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nsi.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mpr.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\userenv.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\profapi.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\AE_MailSensor_Plugin.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\AME_OutlookSensor.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\AME_SmtpSensor.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Program Files\DGAgent\plugins\8E4EA70A-6128-4B57-BD3F-8E9E0F0DA6BB\OS_Plugin.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Program Files\DGAgent\plugins\8E4EA70A-6128-4B57-BD3F-8E9E0F0DA6BB\COM_Sensor.dll'. Cannot find or open the PDB file.
The thread 0x1f34 has exited with code 0 (0x0).
First-chance exception at 0x778412C7 in ConsoleApplication1.exe: 0xC0000008: An invalid handle was specified.

Unhandled exception at 0x778412C7 in ConsoleApplication1.exe: 0xC0000008: An invalid handle was specified.

The program '[1836] ConsoleApplication1.exe' has exited with code 0 (0x0).

So I tried to figure out what's going on by putting a break point at line #5 and stepping with F10. I can step passed the closing bracket of the main() and then enter in a file called "crtexe.c" (see code block below). I continue stepping through this file until the exception pops up at line #649:

645  #else  /* !defined (_WINMAIN_) && defined (_CRT_APP) */
646              if ( !managedapp )
647              {
648  #ifndef _CRT_APP
649                  exit(mainret);
650  #else

What is the explanation for this behavior and how can I get it to work as expected?

Edit: The stack trace is as follow (Since I can't post pictures, I wrote it down):

Call Stack
Name                                                                          Language
ntdll.dll!ZwClose@4()                                                         Unknown
KernelBase.dll!_CloseHandle@4()                                               Unknown
kernel32.dll!_CloseHandleImplementation@4()                                   Unknown
AME_OutlookSensor.dll!732cc94d()                                              Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for AME_OutlookSensor.dll]
AME_OutlookSensor.dll!732b91bc()                                              Unknown
AME_OutlookSensor.dll!732b928f()                                              Unknown
AME_OutlookSensor.dll!732b44c4()                                              Unknown
AME_OutlookSensor.dll!732b461f()                                              Unknown
AME_OutlookSensor.dll!732b468a()                                              Unknown
[External Code]
SBD
  • 41
  • 1
  • 8
  • 8
    use `int main()` and add return statement inside `main`. `void main` is deprecated – taocp Sep 29 '14 at 18:25
  • 6
    `void main()` is not merely deprecated; it's never been legal. I doubt that that's the cause of the symptom, but it certainly should be fixed. – Keith Thompson Sep 29 '14 at 18:31
  • You typed a lot more for those two `using` statements than the two `std::` you would have needed. – crashmstr Sep 29 '14 at 18:55
  • I already tried with int main() { ...; return 0;} but it was the same. – SBD Sep 29 '14 at 19:02
  • 1
    Did you create the project with a VS Wizard? If so did you specify that you were creating a console application (not a windows application)? – Dale Wilson Sep 29 '14 at 19:10
  • 1
    @SBD Did you choose Win32 `Console` Application as the project type? – PaulMcKenzie Sep 29 '14 at 19:11
  • @ Dale Wilson: Yes I used the VS Wizard @ Dale Wilson & PaulMcKenzie: No, I choose "empty project" – SBD Sep 29 '14 at 19:17
  • I just started back from scratch and runned the VS project wizard again. This time I choosed "Win 32 console application" but with the same result when running in debug mode... – SBD Sep 29 '14 at 19:22
  • Do you have an antivirus? If so, try to disable it and run the program again. Just in case... – rodrigo Sep 29 '14 at 19:40
  • Could you list DLLs that were loaded during execution? – Grigorii Chudnov Sep 29 '14 at 19:40
  • I don't see anything expecially wrong with the code. It must be something wrong with Visual Studio. – Claudio Sep 30 '14 at 15:55
  • @Grigoriy Chudnov: I edited my original post with the list of DLLs that were loaded during execution. – SBD Sep 30 '14 at 15:56
  • There is something with the PDB file as the console output says "Cannot find or open the PDB file". – SBD Sep 30 '14 at 15:58
  • Could you set a breakpoint and provide a stacktrace? – Grigorii Chudnov Sep 30 '14 at 18:34
  • @GrigoriyChudnov : I edited the post with the stack trace. – SBD Oct 01 '14 at 19:04
  • 3
    Sounds like it's some brokenness inside `AME_OutlookSensor.dll`. Nothing to do with your program, and nothing you can do here other than perhaps uninstalling whatever application that DLL came from. Looks like that particular DLL has been causing problems [for at least a year now](http://stackoverflow.com/questions/18855190/visual-studio-professional-2012-svhost32-exe-error-running-hello-world). – T.C. Oct 01 '14 at 19:05
  • 1
    I just found this post which re-enforce a concern that I had: http://stackoverflow.com/a/18963244/4091294 . The problem might come from a security application or something the IT guys install on every PC of the enterprise. – SBD Oct 01 '14 at 19:17
  • @SBD, You could try to disable it with [Autoruns](http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx) – Grigorii Chudnov Oct 06 '14 at 19:20

0 Answers0