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 / dim test(1) -> Crash

Author
Message
Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 11th Nov 2012 11:50 Edited at: 15th Nov 2012 13:40
Hi,

I've got a really strange problem. In a program of mine, this function is being executed:



The messages are there for debugging purposes - and as it turns out, message "1", "2" and "3" pop up and then the program crashes (windows error).
I had the same problem like an hour ago. After 20 minutes of attempted debugging and my head nearly exploding due to the lack of logic in all this, the error vanished and everything worked just fine. But now it is back - without any changes being made to the code above in the meantime.

I know I haven't really got much information to provide you with, but does *anybdoy* here have an idea under which circumstances the line 'dim test(1)' could cause such a crash?


Your help is greatly appreciated.
greetings,
MrK



Edit: I just found out something rather interesting.
In the program that crashes, the first thing to be executed is this:



And img_init() is the function that causes the crash. However img_init() is not located in the main file but included. If I compile and run the file containing img_init() with the exact same beginning (display being set and img_init() called afterwards), it works fine. So, the way I see it, the problem has something to do with the rest of the code although it has not even been executed... the mere existence of certain code parts that would come later affects the existence of this crash. What a mess.



Edit 2: It doesn't get better. I found a work around, by simply creating the arrays before the for loops instead of afterwards. For some reason that works. But I'm getting a different illogical error.



The first 4 messages (saving, a, b, c) pop up, then a windows error in the next line "tempS = get dir$()". The function itself seems to work, as I used get dir$() 4 lines above, and assigning values to the tempS variable seems to work as well. But combining those two leads to a crash. Seriously... what the hell is going on here? I've worked with DBP without any problems throughout the last few days, and now that.


Edit 3:

As it turns out, there really is not a problem with get dir$(). In the function above, when I insert this code:



The first message appears, but the second one doesn't due to the usual crash. I have no idea whether this bug is related to the array-crash I had in the beginning.
And once again, usually this code works fine, but in the context of the program I'm working on it crashes for some reason.

Jeff Miller
21
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 11th Nov 2012 15:00
It might help to get all the TYPE declarations completed before calling a function that depends on them. Also, although logically you would expect DBP to fully execute Message 4 before attempting to execute the next dimension statement, who knows? That statement could cause a problem depending on the value of IMG_PERMCOUNT. You might want to make a message at the beginning of the function that painstakingly recites the values of all the variables set outside the function to be sure that they are all legitimate.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Nov 2012 17:15
Your post title says "test(1)" but your code says "temp(1)" and then your text says "temp = get dir$()".

Just typos or indicative of possible errors in your code?
Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 15th Nov 2012 13:39
Oh, sorry, test(1) and temp(1) should actually be the same. I changed the codes several times, thus the inconsistencies. But it doesn't make a difference, the error occurs with both names.

"temp = get dir$()" should actually be "tempS = get dir$()", as in the code.


I haven't used the program I was referring to throughout the last few days, but it would still be nice to find out what's wrong. Any ideas on what it could be, or what I could try to find out?

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Nov 2012 17:11
@Mr Kohlenstoff

perhaps undiming all of the function's local arrays before exiting would help.

Enjoy your day.
Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 15th Nov 2012 20:44
Quote: "perhaps undiming all of the function's local arrays before exiting would help."


Unfortunately they aren't local - the function exists to initialize those arrays so they can be used later, hence that's not really an option.

Login to post a reply

Server time is: 2026-07-11 03:56:12
Your offset time is: 2026-07-11 03:56:12