Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Allebarde

VC++ problem

This topic is 5897 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! When I run my program I get this error: Debug Assertion Failed! Program: Path of my program File: dbgdel.cpp Line : 47 Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) For information on how your program can cause an assertion failure, see the VC++ documentation on asserts What is it exactly? Shall I disable something? I don''t know what to do .. Please Help ) Bye

Share this post


Link to post
Share on other sites
Advertisement
Looks like you''re trying to get from an empty list or something.

Try running the program in the debugger and stepping through your code to find where it''s causing the error.

Share this post


Link to post
Share on other sites
You're doign a linked list or something similar, right? I made a linked tree and got that error when deleting nodes. I have looked through my code several time and it doesn't seem to be any problem with it. My guess is that it's micro$oft who messed up.

Anyway, if you compile with release instead of debug mode, it will work.

If anyone knows what's wrong and how to fix it without compiling in release mode (since debug could be pretty handy at times) me too would like to know.

[edited by - Luctus on April 30, 2002 12:47:55 PM]

Share this post


Link to post
Share on other sites
Erm, I''m pretty sure VC++ doesn''t have any bugs regarding assertions. They aren''t especially complex things, so they tend to either work or not.

Perhaps you could post your code?

Share this post


Link to post
Share on other sites
I think I found the problem: The error occurs when I do:
delete CurrentChunks;
This releases some memory, and the error occurs depending of the 3DS model I want to load..

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
Erm, I''m pretty sure VC++ doesn''t have any bugs regarding assertions. They aren''t especially complex things, so they tend to either work or not.

Perhaps you could post your code?


Hm..let''s say, I think it''s strange I get an assertion error since I''m not even using any assertion functions in my code.

-Luctus

Share this post


Link to post
Share on other sites
quote:
Original post by Luctus
Hm..let''s say, I think it''s strange I get an assertion error since I''m not even using any assertion functions in my code.



This means that you''re passing bad arguments to a system function that has an assert in it to check. If you ignore that and compile in Release mode to get rid of the assert, it''s no longer going to check what you pass in, and your results are going to be undefined. Meaning that your program will probably crash what appears to be "randomly".

Fix the error, don''t ignore it.

Share this post


Link to post
Share on other sites
It has to do with memory deallocation. When you compile your code in debug mode new/delete are handled differently than in release mode. A linked list of valid memory blocks is built up and released throughout your programs life time. If you call delete on an invalid pointer you get this assertion. This assertion can also happen in other circumstances too.

Make sure your variable "CurrentChunks" is pointing to a valid memory location before you try and delete it. It is your bug, not VCs...

Dire Wolf
www.digitalfiends.com

Share this post


Link to post
Share on other sites
Hi!
I have again Memory problems :
The error occured when I did a delete CurrentChunck..
In fact using debug I found where exactly the error was:


Model3ds.pObject[Model3ds.numOfObjects - 1];
Model3ds.numOfObjects++;

//HERE NO PROBLEMS : CurrentChunk is not modified

//allocate some memory
*( &Model3ds.pObject + (Model3ds.numOfObjects-1)*sizeof(Object3DS) ) = new(Object3DS);

//CurrentChunk is not Modified

// Initialize the object and all it''s data members
memset(&(Model3ds.pObject[Model3ds.numOfObjects - 1]), 0, sizeof(Object3DS));

//HERE PROBLEM: CurrentChunck is modified

// Get the name of the object and store it
CurrentChunck->bytesRead += SearchString(Model3ds.pObject[Model3ds.numOfObjects - 1].strName);

Apparately the problem occurs when I set the memory to 0 with memset..
A friend who''s coding under DOS, has the same problem: Can someone help us?
Thanks

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!