[2.4]Portals + polyobjs + BlockLinesIterator heap corruption

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [2.4]Portals + polyobjs + BlockLinesIterator heap corruption

Re: [2.4]Portals + polyobjs + BlockLinesIterator heap corrup

by drfrag » Sat Oct 26, 2019 4:23 am

Superb work as usual. :) I've just ported the fix to LZDoom.

Re: [2.4]Portals + polyobjs + BlockLinesIterator heap corrup

by _mental_ » Sat Oct 26, 2019 2:26 am

Well, this means my commit comments really suck.

DBlockLinesIterator was derived from FMultiBlockLinesIterator.
DBlockLinesIterator::check was passed to FMultiBlockLinesIterator's constructor while it wasn't initialized because parent class' constructor is called before all members' constructors.
The problem was FMultiBlockLinesIterator's constructor is using its check argument.
For this reason, DBlockLinesIterator cannot be derived from FMultiBlockLinesIterator. It should be made a member initialized after check.

Re: [2.4]Portals + polyobjs + BlockLinesIterator heap corrup

by Graf Zahl » Sat Oct 26, 2019 2:13 am

Out of curiosity, why does this kind of change help fix it?

Re: [2.4]Portals + polyobjs + BlockLinesIterator heap corrup

by _mental_ » Sat Oct 26, 2019 2:02 am

Fixed in fb384c6.

Re: [2.4]Portals + polyobjs + BlockLinesIterator heap corrup

by phantombeta » Fri Oct 25, 2019 9:06 pm

Sorry for the bump, but I have some more important, bump-worthy (IMO) info to add:
So it turns out it's even weirder. For some reason, portals combined with polyobjects and BlockLinesIterator causes heap corruption. Unfortunately, this seems to be something I can't figure out how to fix myself.

Re: Consistent, repeatable crash with BlockLinesIterator

by phantombeta » Fri Oct 25, 2019 7:51 pm

Okay, so, it's definitely something to do with portals. I took a moment to look at the callstack, and then it was pretty obvious:

Seems like the "data" TArray in here may not be getting initialized.

[2.4]Portals + polyobjs + BlockLinesIterator heap corruption

by phantombeta » Fri Oct 25, 2019 1:12 pm

Basically what it says in the thread title. Not sure what causes it. I haven't found many maps that cause it, only the WIP training map for my mod. My mod's radar (use "give all" to get it) seems to cause it reliably, though the moment it happens is random.
I don't have a minimal example right now, but I'll try to make one as soon as I figure out what in the map causes it.

Edit: Just speculation, but it might be related to portals. Would explain why I hadn't found the crash when testing in the IWAD maps.

Edit 2: Added a simpler BlockLinesIterator example as an attachment. I also tried to make a simpler map, but couldn't get it to crash reliably.

Edit 3: Updated the thread title. This is nastier than I thought.
Edit 3.1: Updated the thread title to add the first version I can find this in. Uhhhhhhhhh.

Edit 4: Updated the thread title again and added a fully minimal example.
Attachments
Portals-Polyobjs-BlockLinesIterator_crash.PK3
(3.67 KiB) Downloaded 35 times
LineCounter.PK3
(718 Bytes) Downloaded 39 times

Top