[Fix inside]Camera + Morph = 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.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

[Fix inside]Camera + Morph = Crash

Post by Major Cooke »

EDIT: Bugfix PR.

Download the test.pk3 attached. Give SMM in console. A few seconds later, crash.
Attachments
playermorphcrash.zip
Give SMM in console.
(6.45 KiB) Downloaded 45 times
Last edited by Major Cooke on Thu Sep 01, 2016 1:08 pm, edited 8 times in total.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Odd unmorph crashing bug

Post by Edward-san »

it would be interesting to know what are the values of 'type' and, if it's not null, 'i' and 'type->Slot'..
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Camera + Morph = Crash

Post by Major Cooke »

I have managed to reproduce it on a much simpler scale. Attached in the first post is a test example.

"Give SMM" in console. Don't mind the fact that you cannot move.

A couple seconds later, the game crashes from the morph expiring.
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: Camera + Morph = Crash

Post by Graf Zahl »

Still very much 'ugh'.
For some reason it encounters a player class object that isn't fully initialized and crashes on the garbage data.
The big problem is, that cause and effect are in completely separate parts of the code.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Camera + Morph = Crash

Post by Major Cooke »

Youch. Yeah, it is weird when it happens especially because the player's view is just outside of the actor. Hmmm...
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Camera + Morph = Crash

Post by Edward-san »

Regarding the original problem, I got this asan error with the wad:
Spoiler:
and this is gdb backtrace:
Spoiler:
Incidentally, I got another asan error when I just got the morphing item and then directly removed the powerup (no camera switch):
Spoiler:
and this is the backtrace from gdb:
Spoiler:
with these messages from the log before the crash:

Code: Select all

user_lastHP is not a user variable in class DoomPlayer
user_camang is not a user variable in class DoomPlayer
user_dirget is not a user variable in class DoomPlayer
user_dirforward is not a user variable in class DoomPlayer
user_dirside is not a user variable in class DoomPlayer
I wonder what's going on...
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Camera + Morph = Crash

Post by Major Cooke »

Try the new test.pk3.

Now, if you're wondering, overlays are not cleared when unmorphing. Something I told Leonard about but he said they'll be fixed when Actor Overlays are implemented, he said. But as you can see from the new test.pk3, there's no overlays at all.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Camera + Morph = Crash

Post by Edward-san »

urgh please use a different name to the wad instead of the repetitive 'test'. Anyways, I see no change either in gdb and asan output.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Camera + Morph = Crash

Post by Major Cooke »

Meh.

Anyway, anything else I can try to do for this? Or is this something randi has to look into?
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Camera + Morph = Crash

Post by Edward-san »

Can you add a test wad which does just morph and unmorph? In a post above, I mentioned a problem with those steps and would like to check it again.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Camera + Morph = Crash

Post by Major Cooke »

Okay, first post updated. User variables removed.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Camera + Morph = Crash

Post by Edward-san »

It seems that this line in decorate.txt:

Code: Select all

			A_SpawnItemEx("ChaseCam",-10,0,32,0,0,0,0,SXF_NOCHECKPOSITION|SXF_SETMASTER|SXF_ISTRACER,0,32700);
makes sure that the morphed actor's tracer, which points to the actor before morphing, is overridden with the camera:

Code: Select all

	if (flags & SIXF_ISTRACER)
	{
		self->tracer = mo;
	}
from InitSpawnedItem, called by A_SpawnItemEx.

The old actor's information is lost, making the program crash when attempting to unmorph, because it's trying to get the player's info from invalid actor.

In order to fix this, I suspect the old actor pointer should be stored in a different place than the 'tracer'. Graf?
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Camera + Morph = Crash

Post by Major Cooke »

I tested it again just to make sure:

Code: Select all

	Spawn:
		PLAY A 95 NoDelay
		{
			SetPlayerProperty(0,1,PROP_TOTALLYFROZEN);
			A_PrintBold("Camera On");
			A_SpawnItemEx("ChaseCam",-10,0,32,0,0,0,0,SXF_NOCHECKPOSITION|SXF_SETMASTER|SXF_ISTRACER,0,32700);
			ChangeCamera(32700,0,0);
		}
		PLAY A 0
		{
			A_RemoveChildren(true,RMVF_EVERYTHING,"ChaseCam");
		}
This doesn't crash, backing up Edward's words possibly.
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: Camera + Morph = Crash

Post by Graf Zahl »

Edward-san wrote: In order to fix this, I suspect the old actor pointer should be stored in a different place than the 'tracer'. Graf?
Correct. Since it's no longer safe to use tracer for this, a different variable is needed.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Camera + Morph = Crash

Post by Edward-san »

I hope there's nothing which (ab)used the morphed tracer data...
Post Reply

Return to “Closed Bugs [GZDoom]”