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 / Can you have too many function calls?

Author
Message
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Dec 2008 20:22
I have some code which compiles just fine, but crashes immediately with a meaningless "Temp.exe has encountered a problem and needs to close. We are sorry for the inconvenience."

I can stop it crashing by removing a small number of functions. These functions do nothing but call another function many times - no other code involved. Here is an example:



It doesn't matter which functions I remove, I just have to take out a few of the twenty or so that do a similar thing. So I can say it's not a specific piece of code that causes the problem, but the volume of code!

Anybody care to speculate on this one? The program crashes before a single line of code executes - it is not actully calling these functions to trigger the problem. Their mere existence is enough to kill it.

I have updated DirectX and my Graphics drivers to try and remove the problem - no luck.

Here's the annoying part - it fails on one PC, but not another! In fact, the lower-specced laptop is the one that is OK. They are both Win XP.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Dec 2008 21:42
Small update: Tested compiling in Codesurge and standard editor - neither work

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 15th Dec 2008 21:46
I can't see any reason why it should crash, it must be a problem with the compiler.

Care to post a full compilable snippet though?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Dec 2008 22:13
Basic answer: Yes.

I seem to recall that there's a limit, but I can't remember what it is, although it was a total number of functions & types combined.

However, if you hit that limit, I'd expect the compiler to croak, not your program, and I wouldn't expect the code to run at all on any machine.

Any chance that you can upload the exe, or the exb file? Also, which version of DBPro are you running?

kaedroho
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 15th Dec 2008 22:30 Edited at: 15th Dec 2008 22:31
I have a similar problem with UberEngine. On some computers, it just crashes and gives me that message and I have LOADS of functions which have lots of other functions inside. This could be the cause.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Dec 2008 23:53
I'll upload tomorrow - it's on my other machine. Thanks for the thoughts so far.

gamerboots
16
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 16th Dec 2008 00:58
if I understand you correctly this could possibly be a recursive error - as in , function x() calls function y() which calls function z() which in turn calls function x() again (and the cycle continues until your out of memory)
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2008 09:12
I have attached the compiled program. Nothing much will run beyond the menu if you get it working, I'm mid-change with my array system. However, it would be good to see if anybody gets it to fail/succeed. The first thing you should get is a message box saying "Done 1". This is the very first line of code to prove it got started.

A weird thing happened this morning - I compiled with media to upload here, and it worked for me! Then I recompiled without media and it still worked. Recompiled a second time without media, and it failed again. this is the version I have uploaded.

@ Gamer Boots - in this case that is not the problem. The calls are to very simple functions, no recursion. The bigger mystery is that they aren't even called, they cause the program to crash on startup.

sydbod
17
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 16th Dec 2008 09:19
I was under the impression that data gets passed from one function to another through the stack.
If there is too much data in the stack, you will get a stack overflow.
I vaguely remember (but could be just as easily wrong) that there is some flag or setting that will allow the program to assign more memory to the size of the stack.
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Dec 2008 11:04
It works fine for me; the only crashes I got was because some media was missing, but we knew that would happen already.


-> Oh, come on...
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Dec 2008 11:31 Edited at: 16th Dec 2008 11:57
BatVink

I don't know whether that last demo ran correctly or not. Here's what happened:

1. "Done 1" message window appeared.
2. "Done 2" message window appeared.
3. Got a screenful of info saying, among other things, "Initial Memory usage 86" and "Current memory usage 86" and finally something ending with "0".

Then nothing seemed to be happening - and there was no indication whether I should wait or press a key or what, so after a couple of minutes I pressed esc. No obvious crash otherwise.

Hold that! I tell a lie. Out of curiousity I've just run it again and noticed that "Current" changed sometimes when I pressed <return> or minimised then maximised the window. In this case the initial memory is displayed as 74 and current is typically about 64 - and it's still running as I type. And it now says current is 53, so something is definitely happening but I have no idea what.

And it's still running - no crash and my machine is a dinosaur.

@Rudolpho And no missing images either.

Edit (10:33am) And it's still running. Shall I leave it running and see what happens?

Edit2 (10:46am) Still running. Can I stop it please?

Edit3 (10:53) Oops! Closed the window by mistake. But it was still running before I did that. Before I pressed the abort button no other DBP apps would run - and the PC was complaining about a shortage of VM. That seems to be happening a lot lately - especially when DBP programs are running or the DBP editor is open. Any ideas anyone?
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2008 12:53
@GG: The crash is immediate. If you got the "Done 1", it didn't crash. But thanks for your persistence and long-running test

Don't expect to do anything with the program, there is nothing to see. It's only a question of whether it starts at all.

@Sydbod: In this case, there are no functions being called when it crashes. Unless it needs to allocate memory for any potential calls that may happen later?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Dec 2008 12:55
@Batvink
I can see that the DBPro section of the exe is not corrupt and is internally consistent for an executable produced by pre 7.1.

The question is, does it run for you now? Don't recompile, don't start up the editor, just run the program.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2008 15:48
Something to try tonight when I get back to the offending machine. It's 7.0 by the way.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2008 20:36
No - still doesn't work just by running, with no editor open. In fact nothing else was open.

BREAKING NEWS: FIXED IT!!!

The problem is Cloggy's D3D plugin. I opened up that horrible report that you can choose to send to M$ on a crash. It referred to D3Dfunc.dll. Luckily, I only use it in debug mode to mark out the screen coordinates.

Thanks all for the ideas and help. I will let Cloggy know D3D has collapsed again

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Dec 2008 21:27
I love a happy ending.

Login to post a reply

Server time is: 2025-08-09 01:36:47
Your offset time is: 2025-08-09 01:36:47