Page 1 of 2

[Fix inside]Camera + Morph = Crash

PostPosted: Sat Aug 13, 2016 5:23 pm
by Major Cooke
EDIT: Bugfix PR.

Download the test.pk3 attached. Give SMM in console. A few seconds later, crash.

Re: Odd unmorph crashing bug

PostPosted: Sat Aug 13, 2016 5:37 pm
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[i]'..

Re: Camera + Morph = Crash

PostPosted: Mon Aug 15, 2016 9:41 am
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.

Re: Camera + Morph = Crash

PostPosted: Mon Aug 15, 2016 10:02 am
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.

Re: Camera + Morph = Crash

PostPosted: Mon Aug 15, 2016 1:31 pm
by Major Cooke
Youch. Yeah, it is weird when it happens especially because the player's view is just outside of the actor. Hmmm...

Re: Camera + Morph = Crash

PostPosted: Mon Aug 15, 2016 4:30 pm
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 allExpand view
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...

Re: Camera + Morph = Crash

PostPosted: Mon Aug 15, 2016 4:35 pm
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.

Re: Camera + Morph = Crash

PostPosted: Mon Aug 15, 2016 5:00 pm
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.

Re: Camera + Morph = Crash

PostPosted: Sun Aug 21, 2016 8:21 am
by Major Cooke
Meh.

Anyway, anything else I can try to do for this? Or is this something randi has to look into?

Re: Camera + Morph = Crash

PostPosted: Sun Aug 21, 2016 2:28 pm
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.

Re: Camera + Morph = Crash

PostPosted: Thu Aug 25, 2016 1:34 pm
by Major Cooke
Okay, first post updated. User variables removed.

Re: Camera + Morph = Crash

PostPosted: Wed Aug 31, 2016 3:35 pm
by Edward-san
It seems that this line in decorate.txt:

Code: Select allExpand view
         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 allExpand view
   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?

Re: Camera + Morph = Crash

PostPosted: Wed Aug 31, 2016 3:44 pm
by Major Cooke
I tested it again just to make sure:

Code: Select allExpand view
   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.

Re: Camera + Morph = Crash

PostPosted: Wed Aug 31, 2016 3:49 pm
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.

Re: Camera + Morph = Crash

PostPosted: Wed Aug 31, 2016 3:53 pm
by Edward-san
I hope there's nothing which (ab)used the morphed tracer data...