A_Die address zero crash

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
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

A_Die address zero crash

Post by Apeirogon »

If world thing damaged/died event meet monster which call a_die() function, gzdoom crash with vm error "tried to read from address zero", if in such event dont provide check

Code: Select all

if (e.inflictor/damage source/target != null) {other actions}
before accessing inflictor/damage source/target actor.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: A_Die address zero crash

Post by _mental_ »

Please post a runnable sample.

Writing in your native language along with this “English” might help too.
I’m not a native speaker but it’s very hard for me to comprehend this report.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: A_Die address zero crash

Post by Arctangent »

I'm pretty sure he's just running into the issue of not checking for null before trying to access something from an object.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_Die address zero crash

Post by Graf Zahl »

Arctangent wrote:I'm pretty sure...
That's the problem: We are just guessing.
Either we get a more usable description or this will get closed. I have no idea what he did.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: A_Die address zero crash

Post by Apeirogon »

If monster die with null "target" pointer, and I try give something to killer of this monster, gzdoom crash.
Attachments
SDG.wad
(649 Bytes) Downloaded 27 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_Die address zero crash

Post by Graf Zahl »

Code: Select all

		if(ticks >= 150){owner.a_die(); self.destroy(); return;}
That's not correct. It has to be:

Code: Select all

		if(ticks >= 150){ if (owner != null) owner.a_die(); self.destroy(); return;}
If it crashes, that's a different matter.
User avatar
AFADoomer
Posts: 1326
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: A_Die address zero crash

Post by AFADoomer »

A crash is when the engine stops working and gives you an operating system error message. This is not a crash, it is a VM abort.

GZDoom is telling you that you told it to read from an object variable that has never been assigned a value. You must check for null values before referencing a pointer. That is how the engine works.

In addition to what Graf just posted, line 15 should probably check that e.Thing actually had a target before trying to give something to that target:

Code: Select all

if (e.Thing.Target) { e.Thing.Target.giveinventory("healthbonus", 1); }
If you don't do that, and the thing had no target (like if you use the 'kill monsters' cheat), then the engine will abort.
Post Reply

Return to “Closed Bugs [GZDoom]”