Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Random Buffer over run - Bug??

Author
Message
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 3rd May 2009 01:55 Edited at: 3rd May 2009 02:24
Try running the following code:



It causes it a buffer overflow error, any idea why? Is it a bug?

Thanks,
Alex

Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 3rd May 2009 03:26
I copied your exact code, ran it and also got an unhandled exception.

I fixed it by changing:

to


#ifdef _DEBUG
FixBugs(All);
#endif
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 3rd May 2009 03:36 Edited at: 3rd May 2009 03:38
The code below still causes a buffer overrun with suggested changes





Its not an unhandled exception its a buffer over run.

Attachments

Login to view attachments
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 3rd May 2009 03:47 Edited at: 3rd May 2009 03:52
What is weird is that when you comment this out:

TBBUTTON tbButtonst[4];
tbButtonst[1].iBitmap = 3;

You no longer get the buffer overun.

The changes you said above didn't work because the file didn't exist.

I still think this is a bug, the first example should work.

Fails:



Works:



Works:



dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 3rd May 2009 06:36
Quote: "I still think this is a bug, the first example should work."


Why should it? You used a backslash which means an escape character will be invoked; But \T isn't a valid one so it should give you a warning(assuming you have the required warning level set). Also, the point at which it crashes should become obvious once you begin to debug your program. Plus, you should have written safety code to prevent such issues as bad paths from causing errors when loading bitmaps(or whatever your button object does to cause the error).

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 3rd May 2009 11:00 Edited at: 3rd May 2009 11:02
This is not a bug, but I think there should be more error reporting in DGDK to explain what is going on. You are trying to set to an invalid directory which causes the problem. The reason that the buffer overrun doesn't occur if you don't setup the buffers is probably as follows:

1. dbSetDir writes to memory that it shouldn't do. The debugger has not yet realised this.
2. Setting up the buttons writes to this memory, and the debugger realises the error at 1 has occurred.

In C++ any letter after a \ is an escape character, which is just a special char e.g. '\n' is one character. The real backslash character is '\\' which is one backslash.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 3rd May 2009 13:06
Ok thanks for clearing that up.

Also if you specify not existent directory you also get a buffer over run.



AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 3rd May 2009 13:37 Edited at: 3rd May 2009 13:38
DB Load Object also causes a buffer over run with an existent model:



Why is this?

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 3rd May 2009 14:17
Either the object is corrupted in some way, or the object file does not exist.

Try the following:


Basically if you do anything unexpected with DGDK some sort of internal corruption will occur but no DGDK error messages will be displayed. This is pretty incompetent in my opinion, but that's the way it is .

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 3rd May 2009 14:34 Edited at: 3rd May 2009 14:38
Thanks, I agree

For my game I made a kind of wrapper for the DarkGDK functions which gives me more debug info and handles most errors, but now I have started on another project which does not use this, so I never had these kind of messages before.

Login to post a reply

Server time is: 2024-11-05 18:52:23
Your offset time is: 2024-11-05 18:52:23