My program crashes when start with OpenCPPCoverage

May 20, 2016 at 11:12 AM
Edited May 20, 2016 at 11:14 AM
Hi,

I find a strange problem that my program would crash after doing certain operations when start with OpenCppCoverage. But when it is running by itself, no problems will happen.

I tried to debug the crash, but when I use Visual Studio to attach to my program started with "OpenCppCoverage", it reports “Unable to attach to the process. A debugger is already attached". I believe visual studio show this message because OpenCppCoverage itself is implemented as a debugger. So I feel a little hard to debug the crash reason.

Any suggestions on how to debug this crash issue?


Thanks,
Frank
Coordinator
May 22, 2016 at 9:38 PM
Hi,

You are right, OpenCppCoverage uses the same API as a debugger.

First, please check your program is not compiled in release. OpenCppCoverage not yet supports optimized code.

When an application crashes, OpenCppCoverage shows an error message. Can you post it?

Hope that help,

OpenCppCoverage
May 23, 2016 at 3:34 AM
Thanks for the reply. Yes I always use your tools to get code coverage result for my program compiled in release... Actually after turn off the compile optimization (use "/od" instead of "/oi"), and related link optimization, I believe the code coverage analysis result should be same with debug build. My program is a large program that will use many 3rd party dlls. And the program will use release 3p dlls if built with release mode which will run much faster than debug build which uses debug 3p dlls. So in simple words, my program is built in release mode with compile and link optimization turned off on local dlls, but not on 3rd party dlls.

I find 98% of the workflows are running without problems invoked by OpenCppCoverage. Also I can get the correct code coverage result. But there are several workflows which will finally lead to crash. The error code usually looks like follows:

*** Unhandled exception code: 3221225477: EXCEPTION_ACCESS_VIOLATION

I will try use the debug build to see if the crash still happens, will update to you after that.



Thanks,
Frank
May 23, 2016 at 11:29 AM
Hi,

I doubled checked this problem using debug build. What shocked me is... the program will crash directly on debug even without the use of OpenCppCoverage. I had never run into such kind of cases that a program is running well on Release, but crashes on Debug build. I will go on look into the problem to find the real cause.

Anyway, thanks for the good guidance!



Thanks,
Frank
Coordinator
May 28, 2016 at 11:02 AM
Hi,

There is a known issue in release with switch / case. See https://opencppcoverage.codeplex.com/workitem/13 for more information.

Let me know if you have any issue when running OpenCppCoverage with your application in debug mode.

OpenCppCoverage
Coordinator
Sun at 12:14 PM
Hello,

OpenCppCoverage 0.9.6 has a flag --optimized_build to support optimized build.

Let me know if you have any problems.

OpenCppCoverage.