error during VS Debugging but no error when run exe file directly - c++

I have a very simple c++ sample project that basically just logs in to a 3rd party library (collection of .lib files)
There are 4 provided configurations md,mdd,mt,mtd. All x64.
I can build in mdd mode and run the Exe file directly, and the program works fine.
But if I run the debugger in VS, the 3rd party library throws a runtime Exception "vector deleting destructor".
try
{
engine = new Engine(&params);
}
catch (XxxException& Ex)
{
return (ERROR);
}
Exception thrown at 0x00007FFA52003FB8 in Sample.exe: Microsoft C++ exception: XxxException at memory location 0x000000224C53F190.
Exception thrown at 0x00007FFA52003FB8 in Sample.exe: Microsoft C++ exception: XxxException at memory location 0x000000224C53F690.
0x00007ff75d5ab3e0 {Sample.exe!const XxxException::`vftable'} {0x00007ff75d2d8a50 {Sample.exe!XxxException::`vector deleting destructor'(unsigned int)}}
So I am unable to debug.
What is this error, and why does it only occur in VS Debugger?

The solution was to change the working directory as specified in Debugging from $(ProjectDir)
to $(TargetPath), where the exe was sitting!
isn't C++ a wonderful artifact of history!

Related

v8::Isolate::New null access violation

I'm using V8 32-bit Version 4.10.253 compiled with Visual Studio 2015.
I'm trying to run the example that Google has at:
Chrome V8 - Getting Started
But when I try to run it, I get:
Exception thrown at 0x00000000 in V8Test.exe: 0xC0000005: Access
violation executing location 0x00000000.
I get this when the following is executed:
Isolate* isolate = Isolate::New(create_params);
My project settings:
To get the project to compile in debug, I set the runtime library to:
Multi-threaded Debug /MTd.
I include the v8 include directory under additional include directories.
Lastly, I include the following libraries:
icuuc.lib icui18n.lib v8_libplatform.lib v8_external_snapshot.lib
v8_base_3.lib v8_base_2.lib v8_base_1.lib v8_base_0.lib v8_libbase.lib
winmm.lib
Anyone know what I'm doing wrong? Thanks in advance.
Ok, I feel stupid. I didn't finish reading the rest of the tutorial. You must copy all the .bin files where your executable is stored. Specifically:
natives_blob.bin
snapshot_blob.bin
V8 will crash at Isolate::New if you do not.

Unhandled microsoft c++ exception cv exception at memory location

I currently developped a project with VS and OpenCV on my x64 computer and i've a problem with this line:
model->train(image, labels);
image and labels are not empty but i've got this error:
Unhandled exception at at 0x774FC42D in facerec_video.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015EF38.
If i click "continue", program continue and works.
Furthermore, if i set a breakpoint on this line and do a step by step, error message doesn't appear and program works too.
How to resolve this problem ?
Thanks

OpenCV Build ok, debug throws error, runs fine from .exe

Using Visual Studio 2010, OpenCV 2.2.2, Windows 7 64x
My code builds successfully then when it goes into debug I get the following error:
First-chance exception at 0x75f0c41f in MachineVisionHW0.exe: Microsoft C++ exception: cv::Exception at memory location 0x002dec90..
Unhandled exception at 0x75f0c41f in MachineVisionHW0.exe: Microsoft C++ exception: cv::Exception at memory location 0x002dec90..
Then I end debug, go to the file directory and run the built executable and it runs fine. Does anybody know how to fix this? It isn't keeping me from building my code, but it is incredibly inconvenient. I will include an example of the code that is doing this below.
int main(){
cv::Mat image1 = cv::imread("img1.JPG", CV_LOAD_IMAGE_GRAYSCALE);
cv::namedWindow("Sample1");
cv::imshow("Sample1", image1);
cv::waitKey(0);
return 1;
}
Do you get the unhandled exception before main?
If not, then your code is somehow doing something to raise the exception. Put a breakpoint on the first line, then hit F5, then once at the breakpoint, step through the code one line at a time to see which one causes the exception, F10 key to do this.
My gut feeling is that when running from the debugger, the cv::imread is failing since it is not finding the img1.jpg from the expected location, the current working directory is that of the solution file, not of the debug output build dir. You can do a quick test and copy the img1.jpg to the dir containing the sln file and see if that fixes the problem.

Problems running visual studio executables with mono

I'm trying to run with Mono executable files created by visual studio 2010.
Setting in VS 2010 are:
-c++ project
-cil pure
My final target is to compile Parsec benchmarks using visual studio 2010 and then run the executables with mono both in windows and linux.
By now I created a simple c++ project including only a printf.
The executable runs fair with mono under windows, while it gives me back many problems under linux
this is what i get:
** (thread.exe:1424): WARNING **: Missing method .ctor in assembly /home/chezz/Scrivania/thread.exe, type System.Runtime.CompilerServices.FixedAddressValueTypeAttribute
** (thread.exe:1424): WARNING **: Can't find custom attr constructor image: /home/chezz/Scrivania/thread.exe mtoken: 0x0a00000d
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for <Module> ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load.
---> System.MissingMethodException: Method not found: 'System.AppDomain.IsDefaultAppDomain'.
at <Module>.<CrtImplementationDetails>.LanguageSupport.Initialize (<CrtImplementationDetails>.LanguageSupport* ) [0x00000]
--- End of inner exception stack trace ---
at <Module>.<CrtImplementationDetails>.ThrowModuleLoadException (System.String errorMessage, System.Exception innerException) [0x00000]
at <Module>.<CrtImplementationDetails>.LanguageSupport.Initialize (<CrtImplementationDetails>.LanguageSupport* ) [0x00000]
at <Module>..cctor () [0x00000]
--- End of inner exception stack trace ---
Any idea?
Thanks
Andrea
My guess is that the code that the Visual C++ compiler generates will use the MSVCRT if you call functions that are in the C Runtime (i.e. non-.NET, like printf). To be able to run on Mono on Linux as well, you should only use the .NET framework classes (for example System.Console.WriteLine for console output instead of printf).
I believe reading Mono-C++ might help you with your issue. Look towards the bottom about C++ support and the problem with running C++ code.

Is there a simpler Windows C++ Subversion API or an example .vcproj for minimal_client.c?

Following on the tails of my previous (answered) question...
SharpSvn makes calling the Subversion client API simple:
SvnClient client = new SvnClient();
client.Authentication.DefaultCredentials = new NetworkCredential(username, password);
client.CheckOut(new Uri("http://xxx.yyy.zzz.aaa/svn/repository"), workingCopyDir);
On the other hand, calling the client API from C/C++, as shown in minimal_client.c requires coding "closer to the metal", as it were, on Subversion.
Are there Windows libraries for C++ in Visual Studio 2003 that present a simpler interface than what minimal_client uses?
If there are not, is there a VS2003 C++ project (a .vcproj file) that demonstrates getting minimal_client to run? I'm able to compile minimal_client.c and link it using the following libraries:
libsvn_client-1.lib libsvn_delta-1.lib libsvn_diff-1.lib libsvn_fs-1.lib libsvn_fs_base-1.lib libsvn_fs_fs-1.lib libsvn_ra-1.lib libsvn_ra_local-1.lib libsvn_ra_svn-1.lib libsvn_repos-1.lib libsvn_subr-1.lib libsvn_wc-1.lib libapr-1.lib libaprutil-1.lib xml.lib libneon.lib
but when I run my application (in the debugger or start the release build without debugging), it runs for about 20 seconds without hitting the first line of main() and then throws this exception:
An unhandled exception of type
'System.TypeLoadException' occurred in
Unknown Module.
Additional information: Could not load
type apr_pool_t from assembly
minimal_client,
Version=1.0.3477.16033,
Culture=neutral, PublicKeyToken=null.
I've tried various combination of libsvn_.lib and svn_.lib to no avail.
Any thoughts on what I'm doing wrong?
EDIT: I started fresh with a "Win32 Console Project" (still in VS2003) and I am now able to debug the first few lines of my app. But now, on this line:
if (svn_cmdline_init ("minimal_client", stderr) != EXIT_SUCCESS)
I get a different exception (in the debugger or start the release build without debugging):
Unhandled exception at 0x7c91b21a in
Win32ConsoleProject_minimal_client.exe:
0xC0000005: Access violation writing
location 0x00000010.
EDIT: This thread explains that this error is a CRT mismatch between svn and stderr in my app. If I don't want to build Svn so they match (I don't want to), I can pass NULL instead of stderr (provided I'm willing to do without messages that would go to stderr) When I did this, my app ran all the way through correctly.
It seems that C++ wrappers are not overflowing the 'net. However, you may want to try SVNCPP, which can be yoinked from RapidSVN.
See http://rapidsvn.tigris.org/ for details (note: I've not tried it).
Can you upgrade to Visual C++ 2005 ? If so, you could just go using SharpSvn with C++/CLI.
Or even maybe stick to VC2003 and go SharpSvn with Managed C++ ? (not that I have any knowledge on the how od even the if)
edit: oh well, SharpSvn's homepage explicitely states that VC++ 2005 SP1 is required...