[4.13] Random crash with Canvas, maybe

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [4.13] Random crash with Canvas, maybe

Re: [4.13] Random crash with Canvas, maybe

by Rachael » Wed Oct 23, 2024 2:42 am

Are there any global variables that reliably track the engine's "I'm-not-reading-script-code" state that can be used in this case to allow OnDestroy to function as normal?

Would adding the function override to the Canvas class in ZScript as a "final" instead be a viable alternative?

Re: [4.13] Random crash with Canvas, maybe

by dpJudas » Wed Oct 23, 2024 2:07 am

The lifetime of the canvases is tied to the lifetime of textures/textureids in the texture manager. The code was written under the assumption that the texture manager's texture list is static. If 'restart' reinitializes the texture manager then it should indeed need to be cleared at that point.

About changed OnDestroyed behavior in the engine, then yes throwing an exception here will break, but then what alternative is there really?

Re: [4.13] Random crash with Canvas, maybe

by Graf Zahl » Wed Oct 23, 2024 12:02 am

The canvas management is one big mess.
They are held in a static array that is never cleared, so they only get collected when the object system is shut down and the scripted OnDestroy method not called anymore. Should anything change here the error will be thrown in the regular destruction process.

This will also cause problems with the 'restart' CCMD, which should clear the AllCanvases array.

Re: [4.13] Random crash with Canvas, maybe

by Rachael » Tue Oct 22, 2024 6:55 pm

Then done with I_Error, this can be closed as suggested.

Re: [4.13] Random crash with Canvas, maybe

by dpJudas » Tue Oct 22, 2024 4:56 pm

No, Canvas is a collection of engine managed objects. One for each canvas texture in the map.

If I read the Destroy function correctly (been some days ago I looked at it - could be wrong), OnDestroy is called before it marks it for destruction so as long as it doesn't get further everything is still in a sane state.

Re: [4.13] Random crash with Canvas, maybe

by Rachael » Tue Oct 22, 2024 3:56 pm

Isn't Canvas a static object? I think I'd rather fatal error out to avoid the risk of dangly pointers.

Re: [4.13] Random crash with Canvas, maybe

by Graf Zahl » Tue Oct 22, 2024 1:55 pm

I_Error should be enough here.

Re: [4.13] Random crash with Canvas, maybe

by dpJudas » Tue Oct 22, 2024 1:45 pm

I think the following might do the trick, but I'm not entirely sure:

Code: Select all

class FCanvas : public DObject
{
...
  void OnDestroy() override { I_FatalError("Calling Destroy on a canvas object is not allowed."); }
};

Re: [4.13] Random crash with Canvas, maybe

by Rachael » Tue Oct 22, 2024 12:34 pm

The null check actually doesn't do anything useful other than move the problem somewhere else where it can be traced better. Ultimately though, what seems to be the desired solution has not yet been implemented - and that is the blocking of canvas.Destroy()

Re: [4.13] Random crash with Canvas, maybe

by Axensus » Tue Oct 22, 2024 12:22 pm

Should this be closed? As far as I'm concerned, the issue was resolved on the mod's side and I saw Rachael pushed a Canvas-related null check a few days ago, so if this is all taken care of I'll go ahead and delete the test branch. Stale branches bum me out.

Re: [4.13] Random crash with Canvas, maybe

by Axensus » Tue Oct 15, 2024 7:06 am

Fixed on my side. Been a while since I last ran into a blatant [Don't do that]. Turns out setting it to null was sufficient. Guess I used Destroy() because the alternative was to use SendNetworkEvent from UI scope to set the play variable to null. Shouldn't have been THAT lazy.

Re: [4.13] Random crash with Canvas, maybe

by Axensus » Tue Oct 15, 2024 1:43 am

Guess I'll have to look into an alternative solution on my end then.

Re: [4.13] Random crash with Canvas, maybe

by Graf Zahl » Tue Oct 15, 2024 1:23 am

The only way I see is to throw an exception - preferably in the Destroy function, but if that is not doable, when the non-existent camera texture is accessed.

Re: [4.13] Random crash with Canvas, maybe

by dpJudas » Tue Oct 15, 2024 1:02 am

Nice spot, phantombeta. That Canvas.Destroy() is absolutely not allowed. What is the best way to block that?

Re: [4.13] Random crash with Canvas, maybe

by Axensus » Mon Oct 14, 2024 10:55 pm

The inability to reproduce was my fault entirely, sorry. I messed up one of the CVars. Either way, I can't make a smaller example because I don't know what exactly goes wrong but I did make a branch without the randomness (CVar is irrelevant now) so it should make things a lot easier and faster to debug. Plus I remembered you can turn off the TV manually.

https://gitlab.com/accensi/deathstrider ... /crashtest
Fresh crash report just in case: https://files.catbox.moe/8j34ot.zip

However, I found some things while testing this on my laptop where it doesn't always crash after the episode stops. If you walk up to the TV and press use on it to turn it off after starting the level, without having to i_timescale or wait, then use "map map01", it'll immediately crash. Same thing happens when you fire the gun a couple of times, but not always. Pretty sure at least twice it also crashed when I opened the main menu after the menu sound played, though both of those cases require waiting longer. No idea anymore.

Hopefully this helps. As for the loading times, yeah, I really ought to do something about that later today.

@phantombeta:
Strangely enough this worked flawlessly until recently so something's changed. And I couldn't find another way to get rid of a canvas texture back when this was written.

Top