[Won't change] Swapping in a script-constructed StatusBar crashes

Bugs that have been investigated and resolved somehow.

Moderators: Developers, ZDoom.org Team

Swapping in a script-constructed StatusBar crashes

Postby argv » Mon Oct 02, 2017 2:45 pm

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 1 time
bugdemo.pk3
Tries to swap in a new BaseStatusBar. This crashes the game upon entering a map.
(483 Bytes) Downloaded 6 times
argv
 
Joined: 30 Aug 2016

Re: Swapping in a script-constructed StatusBar crashes

Postby _mental_ » Sun Oct 08, 2017 5:07 am

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 allExpand view
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.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Swapping in a script-constructed StatusBar crashes

Postby Graf Zahl » Sun Oct 08, 2017 5:35 am

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Swapping in a script-constructed StatusBar crashes

Postby Major Cooke » Sun Oct 08, 2017 9:24 am

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
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Swapping in a script-constructed StatusBar crashes

Postby Graf Zahl » Sun Oct 08, 2017 10:46 am

It crashes somewhere in native code with an access violation. Those cannot be caught by the VM's exception handler.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Swapping in a script-constructed StatusBar crashes

Postby _mental_ » Sun Oct 08, 2017 10:54 am

I guess Cooke meant to make global status bar read only.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Swapping in a script-constructed StatusBar crashes

Postby Major Cooke » Mon Oct 09, 2017 11:25 am

Not really, mental. I didn't know those crashes couldn't be caught like that.
User avatar
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Swapping in a script-constructed StatusBar crashes

Postby argv » Tue Oct 24, 2017 3:08 pm

Why is it nominally writable, then?
argv
 
Joined: 30 Aug 2016

Re: Swapping in a script-constructed StatusBar crashes

Postby Graf Zahl » Tue Oct 24, 2017 4:05 pm

It is nominally writable because there's a notification call to the status bar from the inventory system that needs it this way.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 1 guest