Activating a SecretTrigger from OPEN ACS script aborts VM

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
User avatar
GFD
Posts: 347
Joined: Mon May 31, 2010 7:42 pm
Preferred Pronouns: He/Him
Location: Canada
Contact:

Activating a SecretTrigger from OPEN ACS script aborts VM

Post by GFD »

Activating a [wiki=Classes:SecretTrigger]SecretTrigger[/wiki] thing from an OPEN ACS script makes the VM abort execution:

Code: Select all

VM execution aborted: tried to read from address zero. In function parameter "self"
Called from Actor.GiveSecret [Native]
Called from SecretTrigger.Activate at gzdoom.pk3:zscript/shared/secrettrigger.txt, line 20
These other similar situations do not cause any problems:
  • The SecretTrigger has already been activated before the OPEN script activates it;
  • [wiki]SetActivator[/wiki](AAPTR_NULL) has been run in the OPEN script before it activates the SecretTrigger;
  • A void script activates the SecretTrigger.
I've attached a simple test map with one SecretTrigger thing and two ACS scripts. The switch in front of the player runs a "ActivateSecretThing" ACS script that activates the SecretTrigger. The switch behind the player is assigned [wiki]Thing_Activate[/wiki] directly. The OPEN script's behaviour depends on the current difficulty level:
  • Below HMP (3), it activates the SecretTrigger after 70 tics.
  • On HMP, it activates the SecretTrigger immediately.
  • Above HMP, it never activates it.
Amusingly, this isn't the first time this mapping error in BadgerZE has made ZDoom unable to load it.
Attachments
SecretTriggerVMCrash.wad
(2.48 KiB) Downloaded 31 times
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: Activating a SecretTrigger from OPEN ACS script aborts V

Post by Graf Zahl »

It shouldn't crash, of course, but without an activator the secret cannot be credited so the best outcome is that it won't do anything at all.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Activating a SecretTrigger from OPEN ACS script aborts V

Post by _mental_ »

The secret was counted as found before scriptification.

Graf, is it OK to fix it like this?

Code: Select all

DEFINE_ACTION_FUNCTION(AActor, GiveSecret)
{
    // was
    //   PARAM_SELF_PROLOGUE(AActor);
    // and replaced with two following lines to avoid null check
    PARAM_PROLOGUE;
    PARAM_OBJECT(self, AActor);
    PARAM_BOOL(printmessage);
    PARAM_BOOL(playsound);
    P_GiveSecret(self, printmessage, playsound, -1);
    return 0;
}
Can be fixed in secrettrigger.txt but the secret won't be credited thus breaking compatibility (if this term is applicable to our case).
The code I posted allows to keep old behavior although I'm curious about possible side effects of altering function prologue 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: Activating a SecretTrigger from OPEN ACS script aborts V

Post by Graf Zahl »

No. In general all object methods must never be called with a null self pointer. So if this function must be callable with a null self pointer it needs to be static or preferably part of the LevelInfo struct. (Keep the Actor version in case something depends on it, though.)
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Activating a SecretTrigger from OPEN ACS script aborts V

Post by _mental_ »

Like this?
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: Activating a SecretTrigger from OPEN ACS script aborts V

Post by Graf Zahl »

Looks correct from a quick check.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Activating a SecretTrigger from OPEN ACS script aborts V

Post by _mental_ »

Fixed in 69e7bb5.
Post Reply

Return to “Closed Bugs [GZDoom]”