Swapping in a script-constructed StatusBar crashes
Moderator: GZDoom Developers
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.
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.
Swapping in a script-constructed StatusBar crashes
I tried to construct a new, custom BaseStatusBar implementation from ZScript, and write the reference to it into the global StatusBar variable. This appears to be permitted, in that StatusBar isn't readonly, but doing so crashes the game.
I had hoped to use this to allow a single mod to offer several different HUD styles, including a legacy style that's based on SBARINFO (so I can't just factor it out into a separate class with its own draw method).
I've attached a minimal pk3 demonstrating the problem (named “bugdemo.pk3”) and the resulting crash report (“CrashReport.zip”).
I had hoped to use this to allow a single mod to offer several different HUD styles, including a legacy style that's based on SBARINFO (so I can't just factor it out into a separate class with its own draw method).
I've attached a minimal pk3 demonstrating the problem (named “bugdemo.pk3”) and the resulting crash report (“CrashReport.zip”).
- Attachments
-
- CrashReport.zip
- Crash report.
- (17 KiB) Downloaded 23 times
-
- bugdemo.pk3
- Tries to swap in a new BaseStatusBar. This crashes the game upon entering a map.
- (483 Bytes) Downloaded 30 times
Re: Swapping in a script-constructed StatusBar crashes
I don't know was it intentional or nor to have status bar assignable from a script.
However an active status bar cannot function properly with player attached to it. So at least the following line needs to be added to the sample:
There are several places in code where checks for player are missing. Probably status bar is not suitable for such replacement indeed.
However an active status bar cannot function properly with player attached to it. So at least the following line needs to be added to the sample:
Code: Select all
sb.AttachToPlayer(players[consoleplayer]);
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Swapping in a script-constructed StatusBar crashes
Note: Just because a global variable is nominally writeable does not mean you are allowed to write to it!
In clear English: Don't do that! If you think you have to, you need to investigate yourself what is needed to properly set up your stuff.
But regardless, this is absolutely not how statusbars should be installed. Use the proper mechanisms instead!
In clear English: Don't do that! If you think you have to, you need to investigate yourself what is needed to properly set up your stuff.
But regardless, this is absolutely not how statusbars should be installed. Use the proper mechanisms instead!
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Swapping in a script-constructed StatusBar crashes
I think what aught to be done is change it so it'll give a VM abort, instead of letting it crash. It'll be a lot easier to debug these kinds of problems this way.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Swapping in a script-constructed StatusBar crashes
It crashes somewhere in native code with an access violation. Those cannot be caught by the VM's exception handler.
Re: Swapping in a script-constructed StatusBar crashes
I guess Cooke meant to make global status bar read only.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Swapping in a script-constructed StatusBar crashes
Not really, mental. I didn't know those crashes couldn't be caught like that.
Re: Swapping in a script-constructed StatusBar crashes
Why is it nominally writable, then?
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Swapping in a script-constructed StatusBar crashes
It is nominally writable because there's a notification call to the status bar from the inventory system that needs it this way.