Swapping in a script-constructed StatusBar crashes

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: Swapping in a script-constructed StatusBar crashes

Re: Swapping in a script-constructed StatusBar crashes

by Graf Zahl » Tue Oct 24, 2017 3: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.

Re: Swapping in a script-constructed StatusBar crashes

by argv » Tue Oct 24, 2017 2:08 pm

Why is it nominally writable, then?

Re: Swapping in a script-constructed StatusBar crashes

by Major Cooke » Mon Oct 09, 2017 10:25 am

Not really, mental. I didn't know those crashes couldn't be caught like that.

Re: Swapping in a script-constructed StatusBar crashes

by _mental_ » Sun Oct 08, 2017 9:54 am

I guess Cooke meant to make global status bar read only.

Re: Swapping in a script-constructed StatusBar crashes

by Graf Zahl » Sun Oct 08, 2017 9:46 am

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

by Major Cooke » Sun Oct 08, 2017 8: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.

Re: Swapping in a script-constructed StatusBar crashes

by Graf Zahl » Sun Oct 08, 2017 4: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!

Re: Swapping in a script-constructed StatusBar crashes

by _mental_ » Sun Oct 08, 2017 4: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 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.

Swapping in a script-constructed StatusBar crashes

by argv » Mon Oct 02, 2017 1: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 22 times
bugdemo.pk3
Tries to swap in a new BaseStatusBar. This crashes the game upon entering a map.
(483 Bytes) Downloaded 24 times

Top