DIV ARENA FORUMS

Possible bug with let_me_alone function

josepgames - 5-12-2016 at 10:04 AM

Hi,

I've noticed a possible bug with let_me_alone function. In many of my games, when I finish a level (or user wants to go back to main menu) I execute let_me_alone() process in order to kill all running processes and load next level (or main menu level).

In some cases, after running let_me_alone process and running debugger I see a negative number of running processes. This makes next "frame" command to exit game (I guess is because it has an inconsistent number of processes to render). I attach some screenshots. I'll try to create a sample program to reproduce the error. I detected It running New-Pacman game (http://div-arena.co.uk/forum2/viewthread.php?tid=151) by:

1) Ener 1st level
2) Play a while until pacman shield disappears
3) Open debugger and add a break at "menu_principal" process
4) Hit "Esc" key to go back to main menu
5) You'll see negative processes and when rendering next frame program crashes

I'm compiling games with latest nightly build under Windows 7.

Any help will be appreciated!

Thanks

Josep


newpac_after_let_me_alone1.png - 41kB

BreadCaster - 5-12-2016 at 12:09 PM

Hi Josep

From what I can see, the let_me_alone is inside a function - functions by their very nature are self terminating and are used to grab quick pieces of information/return certain results rather than keeping on running in the background, so what's likely happening is your function there is self terminating and then there's nothing to keep the program running. If you use let_me_alone inside a process with a Loop and Frame you should be fine :)

josepgames - 5-12-2016 at 12:37 PM

Hi BreadCaster,

Thanks for your quick reply. No, I'm not calling let_me_alone inside a function, it's always under the main program section.

I attach source file, in case you want to take a look...

Thanks!!

[Edited on 5-12-2016 by josepgames]

Attachment: NEWPAC.PRG (119kB)
This file has been downloaded 2104 times


josepgames - 5-12-2016 at 12:42 PM

Some more info... Game worked fine when it was compiled under DIV 2 & MSDOS this bug only raises under DIV DX compilation and Windows 7 (same source code compiled). So it seems to be a DIV DX bug

Thanks!

josepgames - 5-12-2016 at 04:20 PM

Hi,

I found what causes the crash and a possible workaround.

The problem is I was calling stop_scroll and let_me_alone:

Code:
let_me_alone(); stop_scroll(SCROLL_CELDA);


As the documentation states, stop_scroll sends a kill signal to all its inner processes. The same is done by let_me_alone procedure, but for all processes except the one who calls it. It seems there's a conflict between these two calls which returns a negative number of processes (maybe counts scroll process delete twice), and DIV DX fails when you start the process which returns the process counter back to 0.

The workaround for this code (in my case) was to run only stop_scroll and call let_me_alone only before an exclusive process (like rendering a new level or showing main menu).

Even though I made it work, this is an issue related to stop_scroll or let_me_alone. One of those two functions (when called sequentially) decreases process counter below 0 and should be fixed to avoid further errors. Hope this gives you enough info for the fix.

I'll be glad to help if you need further info!!

stop_scroll_and_let_me_alone.png - 27kB

MikeDX - 6-12-2016 at 01:01 AM

This is an interesting bug and fixing it probably fixes some other issues with games that quit.

Thanks for the report!

josepgames - 6-12-2016 at 07:16 AM

Thanks mike!

Just to clarify, div exits when raises the process which sets process counter back to zero. However, process which set process counter below zero should be fixed anyway.

If there's anything I can do to help fixing it or testing I'll be glad to help!