Swapping in a script-constructed StatusBar crashes

Bugs that have been investigated and resolved somehow.

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.
Post Reply
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Swapping in a script-constructed StatusBar crashes

Post by argv »

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”).
Attachments
CrashReport.zip
Crash report.
(17 KiB) Downloaded 18 times
bugdemo.pk3
Tries to swap in a new BaseStatusBar. This crashes the game upon entering a map.
(483 Bytes) Downloaded 24 times
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Swapping in a script-constructed StatusBar crashes

Post by _mental_ »

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:

Code: Select all

sb.AttachToPlayer(players[consoleplayer]);
There are several places in code where checks for player are missing. Probably status bar is not suitable for such replacement indeed.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Swapping in a script-constructed StatusBar crashes

Post by Graf Zahl »

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!
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Swapping in a script-constructed StatusBar crashes

Post by Major Cooke »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Swapping in a script-constructed StatusBar crashes

Post by Graf Zahl »

It crashes somewhere in native code with an access violation. Those cannot be caught by the VM's exception handler.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Swapping in a script-constructed StatusBar crashes

Post by _mental_ »

I guess Cooke meant to make global status bar read only.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Swapping in a script-constructed StatusBar crashes

Post by Major Cooke »

Not really, mental. I didn't know those crashes couldn't be caught like that.
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Re: Swapping in a script-constructed StatusBar crashes

Post by argv »

Why is it nominally writable, then?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Swapping in a script-constructed StatusBar crashes

Post by Graf Zahl »

It is nominally writable because there's a notification call to the status bar from the inventory system that needs it this way.
Post Reply

Return to “Closed Bugs [GZDoom]”