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 / Buffer Overflow

Author
Message
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 13th Jul 2007 00:21 Edited at: 13th Jul 2007 00:22
Hi dbStatisticis giving me a BO..it suposely returns an integer, here's the code.



Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 13th Jul 2007 21:33
Hasn't this happened to anyone? It doesn't make any sense...

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 13th Jul 2007 22:56
out of curousity, what happens if you do dbText(1,10,str)?

My DBP plugins page is now hosted [href]here[/href]
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 14th Jul 2007 03:09
same thing

Chalkey
17
Years of Service
User Offline
Joined: 25th May 2007
Location:
Posted: 14th Jul 2007 14:07
To Jna99

I think its something to do with the amount of objects you have. The more objects the more polygons which will return a larger value, which I think will cause your str[] array to overflow.

I made a small program with only one cube and it ran fine, then I added a for loop, created 1000 cubes and it gave me a buffer overflow...

Not entirely sure though,
Andy
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 16th Jul 2007 20:51
Chalkey I believe a buffer of 128bytes can fit 2 objects?

Chalkey
17
Years of Service
User Offline
Joined: 25th May 2007
Location:
Posted: 17th Jul 2007 02:06
To Jna99

When you declare your array char str[128] it means it can have 129 elements - a max of 129 char's (C++ arrays start from 0).

It was just a guess, but i thought that possibly if you have a lot of objects in your 3D scene and you use the dbStatistic() to get the number of polygons, if its a large number and you add that to the end of the array str but there isnt enough space for it to fit, you will get an overflow. You might be mistaken the size of an array for the amount of bytes it will take in memory.

This little program for me works with no buffer overflow...


That prints out the FPS and the number of polygons and works okay. Sorry if this hasnt been helpful...

Chalkey
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 17th Jul 2007 02:17 Edited at: 17th Jul 2007 02:18
Chalkey I've 2 objects 1 light 3 vectors and 1 shader



Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 17th Jul 2007 03:58 Edited at: 17th Jul 2007 04:01
I'm not sure anyone's realised this but the highest number that dbStatistic returns can only be 10 digits long (2147483647 I think). Are you sure the error is occurring on that particular line?

Quote: "When you declare your array char str[128] it means it can have 129 elements - a max of 129 char's (C++ arrays start from 0)."

This is actually incorrect, in C++ the highest index of an array is n-1. In other words, an array declared with a size of 128 will give you a highest index of 127 (thus 128 items).

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 17th Jul 2007 15:11
Yep I believe I've figure it you , I can't for some reason the strcpy or the sprintf function make the program overflow when I'm using shaders, I know this doesn't make any sense but look at the code above
I'm also using this libs <stdio.h> <stdlib.h> <string.h><"DarkGDK.h"

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Jul 2007 21:27
I assume you tried removing that construct you posted - to make sure its not something else choking your code? BTW - I'm not being smart - I've chased many bugs that were something TOTALLY different than what they seemed (or said) they were.

Know way too many languages - Master of none

Login to post a reply

Server time is: 2024-10-09 00:26:12
Your offset time is: 2024-10-09 00:26:12