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.

DarkBASIC Professional Discussion / Function pointers and data statement issue ???

Author
Message
Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 24th Jan 2015 19:06
I encounter a strange bug, let show it with a few line of code:
make sure you have Matrix1Utils installed



runs OK..


Introduce a function pointer:



Still OK...


Introduce a data statement:




And the app silently exits without saying goodbye......
Same thing with ordinal instead of function name..


1) Can anyone confirm ? I'm running rc7 and Windows Vista... maybe something wrong with my dbp install..

2) Is there a stupid thing I forgot ?

3) Anyone has a clue ???

Thanks..

All hail the new flesh
Burning Feet Man
17
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 24th Jan 2015 23:53
I recall seeing this problem previously. Although there is a small syntax issue in your final example, the problem remains even after correcting;



From memory, I think other threads discussing this bug came to the conclusion of, don't use the DATA command (but I could be wrong).

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Jan 2015 00:47
This is just conjecture on my part, but the data statements actually insert values into a contiguous block stored in the executable itself when it is compiled. The get ptr to function functions probably just assume that the function table of the executable start at a certain offset, but the data block comes before that and as such offsets this table, making it read what it thinks is the proper function address. When then calling this function address you'll get a crash because there is no runable code at the pointed-to location. Funkier things could probably happen if whatever the pointer is pointing to does indeed correspond to a valid function declaration (you could probably even try to hack your own binary functions into your programs using the afforementioned DATA statements and attempt to execute that... that could be an interesting undertaking actually ). Of course it is extremely unlikely that an invalid function pointer offset read in this manner will actually resolve to executable code and as such the crash is the most likely outcome.

Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 25th Jan 2015 02:32 Edited at: 25th Jan 2015 02:32
Thank you for responding,
Indeed the issue has already been discussed and I missed it:
http://forum.thegamecreators.com/?m=forum_view&t=206498&b=1
So I will work around this!

All hail the new flesh

Login to post a reply

Server time is: 2025-05-14 04:06:04
Your offset time is: 2025-05-14 04:06:04