Unusual Crash (Demo Included)

I'm stumped...


I decided to recreate an old event-based slot machine I worked on a couple of years ago as a one-week project. The challenge is to recreate the functionally without the aid of scripts; scripts are low priority and can only be used for aesthetic or user-friendly purposes. So I finish designing and implementing the foundation of the system, which seems to work as intended until you 'spin the reels' about 20 or so times. At this point the game crashes:


element_slots_issue_00.PNG


I did find out where it's happening, but I don't know what exactly is causing it...


element_slots_issue_01.PNG


element_slots_issue_03.PNG


I've included a download to the non-encrypted file since complete screenshots of all of the events involved would be unreasonable. The project has two scripts installed, one of which is a backtrace that I added after I found this issue (seen working in console screenshot above). The other is a tiny bit of code I wrote to display gold as dollars.


I don't need to mention this to any programmers who may be reading, but I'll bring it up anyway.


I'm guessing Game_Interpreter:119 is probably referring to command_119


#--------------------------------------------------------------------------
# * Label
#--------------------------------------------------------------------------
def command_118
end
#--------------------------------------------------------------------------
# * Jump to Label
#--------------------------------------------------------------------------
def command_119
label_name = @params[0]
@list.size.times do |i|
if @list.code == 118 && @list.parameters[0] == label_name
@index = i
return
end
end
end


Or line 119


#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@fiber.resume if @fiber
end


I'm not sure which it is honestly...


To recreate this crash, simply play for about 20 to 22 rounds. It should crash as soon as you bid any amount of credits.


I'd really appropriate any feedback as to what the problem might be. Thanks for reading.


How To Play

Spoiler
Once you begin a new game. Grab the money out of the chest just below the player.


element_slots_issue_04.PNG


From there, activate the switch just above the player. You'll get a display like so:


element_slots_issue_05.PNG


You need to play about 20 rounds of the game, so go ahead and insert all or most of the money into the machine.
Credits will increase and money will decrease each time you select an option.


element_slots_issue_06.PNG



Press Esc when you're done adding money to get to the main menu.


element_slots_issue_07.PNG


From there, select 'Play Slots' which will take you to bidding menu.


element_slots_issue_08.PNG


Select any of the betting options and the game will begin.


element_slots_issue_09.PNG


After you've made your bet and won or lost credits you will return the betting menu.


element_slots_issue_10.PNG


Continue to this about 20 times to get the crash. Press Esc to return the main menu.
From the main menu, press Esc again to exit the game.  Selecting 'Cashout' from the


main menu will convert credits back into money and return it to the player.


element_slots_issue_11.PNG


element_slots_issue_12.PNG



Download


View attachment ESlots_Remaster.exe
What's actually meant to happen here?  I interact with the switch once and it just keeps looping through, increasing credits, decreasing my $$$.  I've done 40 rounds and no crash so far.


Edit: 50 rounds, it tells me I've run out of money but keeps asking me to insert money.  Still no crash.  The slot images never change.


Game_Interpreter::119 is referring to line 119.
@Shaz
Oh right, I was planning to implement a mouse system where you'd just need to right-click to cancel.


Once you're finished adding credits, hit escape to get to the main menu.


Sorry about that.


Edit: 20 or so rounds of actually playing the game need to be done before the crash happens.
I updated my post while you were posting.


The slot images never change, and I can go 50 rounds without a crash.
@Shaz


That's odd... I'll try making a video to show what's happening on my end. It's the exact same project so I don't see how anything can be happening differently.
are you saying your slots change images?  Oh wait - it's just an animated version of the same thing. In that case it's okay.  I was expecting ... slots.


Is this how you're planning to run it - in a neverending loop?  Or do you intend for the player to use the switch each time they want to run it?  If so, make it the way it's going to end up.  Putting it in a loop could be what's causing your problem, though I'm still unable to reproduce the crash.


I don't know that a video is going to be of any help.


What version of Ace are you using?


edit - wait a minute ... got the sprites to change, and the crash.  Some more detail on how to use the system would have helped.  I wasted a lot of time doing completely the wrong thing.
@Shaz
I'll update my post with details on how to play.


Edit: Done. Hindsight...


Edit: Well... I think I figured out what's causing it.


Turns out there's a limitation as to how many common events call be called in succession.
I think it's around 85 times. It seems that the previous common event isn't disposed of when


calling a common from within a common event... I guess it's trying to run them all at once?
Somehow this doesn't create any lag like a bunch of parallel processes would, but I guess


there's information of some kind that isn't being disposed of until the common event chain


actually ends. I doubt this happens with map events, but I haven't tested that out yet.



This is my theory after running this test:

Spoiler
element_slots_issue_13.PNGelement_slots_issue_14.PNGelement_slots_issue_15.PNG

Hit enter about 84/85 times and it should crash with a stack too deep error. Kind of annoying to test I know.


You could just set up a loop as well, but I only just thought of that while writing this. xD

Not sure if I should treat this as a bug, engine limitation, or me simply doing things wrong. I found that I can get around the crash from the slot machine by cashing out occasionally. Obviously, that isn't an acceptable fix. My options at this point are to redesign the event or delve into the interpreter and try to correct this with a bit of coding.


Edit: Thinking on it a bit further, it makes since as to why this would happen.

Generally when you call a common event, it runs then returns to processing the event from which it was called...
My current setup just keeps calling new instances of common events over and over again, bogging down the interpreter.
It never gets a chance to return to the event processing from which it was called because it's constantly calling new


events... If I'm right about this, I think I know how to fix the common events without changing too much.
I managed to fix it using a few labels instead of common event calls to return to previous menus.

Original thread: https://forums.rpgmakerweb.com/threads/unusual-crash-demo-included.66983/