Jump to content
  • Advertisement
Sign in to follow this  
ehmdjii

crash when running standalone

This topic is 4886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i use VS.NET2003 to build my application. it builds and runs fine in release and debug mode, as long as i run it out of the VS-IDE. but when i want to start my program alone, without VS, it crashes at a certain point. what could be the problem and how can i debug it? thanks! edit: i get this error from windows: --------------------------- Microsoft Visual C++ Debug Library --------------------------- Debug Assertion Failed! File: dbgheap.c Line: 1132 Expression: _CrtIsValidHeapPointer(pUserData) For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

Share this post


Link to post
Share on other sites
Advertisement
This probably has to do with the directory the executable is running from. When you run from the IDE, the default directory is the directory that contains the project file (.proj). If you run the application from explorer, then you are running from the .../Debug or .../Release directory. When your application goes to load resources, it can't find them.

Of course, if you aren't loading any resources, then none of this has anything to do with your problem. ;)

Share this post


Link to post
Share on other sites
no, it doesnt load any ressources

and the crash doesnt occur at program startup, but after the program is running already.
to be exact, it happens when a certain class is created a number of times.

Share this post


Link to post
Share on other sites
Ok. That's different, as you guessed.

Since you can't reproduce it in the IDE, I would recommend you put some MessageBox calls at strategic points in your code and run it outside the IDE. That will give you some idea where it's happening and then you can add more MessageBox calls to narrow it down further.

From the assertion, it looks it may be trying to use a pointer that has been deleted/released.

Share this post


Link to post
Share on other sites
Two words: "Uninitialised variables"
Even running your exe under release build through the debugger still initialises some variables to the same value each time. Only when you run without debugger does it not initialise them, causing unpredictable results for uninitialised variables.
In this case, perhaps check for a pointer that is not being initialised to NULL.

Share this post


Link to post
Share on other sites
From MSDN:

_CrtIsValidHeapPointer verifies that a specified pointer is in the local heap.

As iMalc said it seems you have an uninizialized pointer somewhere in your code ...

Share this post


Link to post
Share on other sites
thank you!

and there is no way to find out which pointer that is?

as i said, the error occurs after a certain class is instantiated a couple of times.

so the first 5 times it works, but on the 6th one it crashes....

Share this post


Link to post
Share on other sites
If the error doesn't occur in debug mode (have you checked the output window?) the only thing I can think of (if you don't find the mistake by looking at the code) ist to check each pointer with the IsBad*Ptr functions:

IsBadReadPtr
IsBadWritePtr
IsBadStringPtr

They return 0 if the pointer is not valid for read/write operations or doesn't point to a 0-terminated string ...

However I think it's easier to look through the code for uninitialized pointers than adding ASSERTS (with these functions as the parameter) everywhere ...

Share this post


Link to post
Share on other sites
When the assertion box appears, one of the options should be to debug the application. That should start up VS in the debugger. Then you can look at the variables and/or stack trace to find out where it is.

If you don't get a debug option, then you might try my suggestion of adding message boxes to narrow down where the crash occurs.

Share this post


Link to post
Share on other sites
thank you very much everybody.

with uninitialized pointers you mean i do something like:

myclass * A;
A = &B;

without doing the new() operator on A?


still, i dont really understand why this error doesnt occur within the VS IDE? anyone care to explain it to me?

thanks!

edit:
Dave, yes i can debug the application, but it doesnt always end at the same place. sometimes it gives me a read-violation in free.c sometimes in xtree and sometimes there is no source available at all.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!