ID:2644787
 
BYOND Version:513
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 86.0.4240.198
Applies to:Dream Daemon
Status: Deferred

This issue may be low priority or very difficult to fix, and has been put on the back burner for the time being.
Descriptive Problem Summary:
Crashes whenever I try to run and join this game. The length of time it takes to occur is random, anywhere from immediately, to 30 minutes or more.

Numbered Steps to Reproduce Problem:
Start Dream Daemon, run game (also happens if I run the game outside of Dream Daemon, it'll just crash the client, however. I can provide that error log as well if I need to.)
Literally opening this game with any version of BYOND
Code Snippet (if applicable) to Reproduce Problem:
See below.


Expected Results:
I guess not crashing.
Actual Results:
dreamdaemon.exe
5.0.513.1539
5fdc4c96
byondcore.dll
5.0.513.1539
5fdc4c15
c00000fd
000f27a6
23a8
01d6dca22051acf3
C:\Program Files (x86)\BYOND\bin\dreamdaemon.exe
C:\Program Files (x86)\BYOND\bin\byondcore.dll
582f8166-a9e6-48bd-8ea7-b4033678d673

Does the problem occur:
Every time? Or how often?
Yes, every time, even on earlier versions, though less so on older versions from around 2015 or so.
In other games?
Unsure, haven't had the opportunity to try other sources.
In other user accounts?
Everyone I've shared the source with.
On other computers?
Same as above.

When does the problem NOT occur?
Unsure, this source is the only one I've actually tried, but everyone seems to have this problem.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Yes, sort of. It's less volatile in earlier versions of BYOND, to where I can play for an indefinite period alone, but when with others, it's random, just as before.

Workarounds:
If I don't join at all, the game runs quietly in the background without any issues, and Dream Daemon does not crash.
Do you have the source for this game so I can try to replicate this? I'll trace your crash and see where it's going wrong if I can (it's a stack overflow but that's all I can tell at a glance) but it would be best if I can get the problem to occur on my end in the debugger.
In response to Lummox JR
Yup, I just paged you.
I just did a trace and it appears this stopped early in DoProc(), the workhorse that handles proc calls, which means somehow the stack overflowed earlier than the built-in recursion limit would have expected. I'll run your code next week and see if I can get it to happen in the debugger, which should explain more.
Alright, thank you, I appreciate it!
I was able to run your code in the debugger and the problem occurred pretty quickly.

The issue appears to be in your Bump() proc. Specifically, in a number of situations you're calling step_rand() in response to a bump, where it would seem there is no viable place to step that wouldn't initiate another bump. (I believe step_rand() already takes density into account although I'd have to confirm that, but it doesn't take anything else into account.) Therefore you're bumping ad infinitum and the stack breaks. So the logic really needs a rethink, or at least a way to bail out after more than one failure.

The Bump() proc is pretty grotesque though and I would advise rethinking it. You have some logic in there that's really NPC-specific, and a bunch that's player-specific, and it seems like you could override Bump() and have separate versions for each. Also usr makes an appearance in this proc, which should never happen.
In response to Lummox JR
Alright, thank you. I'll see what I can do with it. I appreciate the help.
I'm going to mark this issue as deferred, since the level of fine-grained control I would need to avoid a stack overflow in this situation is very difficult and probably not worth throwing a lot of time into right now.
Lummox JR changed status to 'Deferred'