[Fixed] crash with SetViewPos / ViewPosition class

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.

crash with SetViewPos / ViewPosition class

Postby crashm » Fri Apr 01, 2022 7:53 pm

I've included a sample pk3 that's just a playerpawn with a Tick() override that calls SetViewPos, all you have to do to get it to crash with a Very Fatal Error is start a new game, save, then load a few times.

Checking it out in the Visual Studio debugger seems to show that the engine is trying to destroy a ViewPosition object that doesn't exist.
You do not have the required permissions to view the files attached to this post.
crashm
 
Joined: 01 Apr 2022

Re: crash with SetViewPos / ViewPosition class

Postby Graf Zahl » Fri Apr 01, 2022 11:53 pm

Looks like this was not properly implemented. The data being used here was not properly declared for the garbage collector.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: crash with SetViewPos / ViewPosition class

Postby Major Cooke » Sat Apr 02, 2022 12:19 am

Apologies for this. I was trying to go by how you suggested the overhaul be like for things like sprite rolling where data's minimized and only called when needed.

If there's a better way to handle this from here on out, I'd love to know.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: crash with SetViewPos / ViewPosition class

Postby Graf Zahl » Sat Apr 02, 2022 12:59 am

It's not that complicated. If you declare a pointer to a DObject-derived class, you need to add two things:

First, wrap the pointer in a TObjPtr and second, add a declaration to the containing class's pointer list. These two things are needed so that the GC can properly handle the object. What happened here is that the GC threw out the ViewPos object because it did not know about it but left the stale pointer untouched, which obviously resulted in a crash.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests