Infinite loop in MapLoader::FixHoles()

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
gtprst
Posts: 1
Joined: Tue May 21, 2024 8:55 pm

Infinite loop in MapLoader::FixHoles()

Post by gtprst »

First, hello!
Second, thanks for all your hard work! I've played GZDoom for years. It's my favorite source port.
Third, I'd like to report what seems like a bug that I've found.

I have created a map and as I was detailing a room, I reached a point where I could no longer test my map, GZDoom (g4 11.3) hangs on load. I'm not sure what causes it. I found an area where I can add a linedef to cause it, and remove it to resolve it (to load the map normally). I also found a place where I cloud flip a linedef's facing and that would cause the map to hang on load.

I downloaded the source and built a Debug build of branch master (on Windows 10 using Visual Studio 19). The start screen says this is version `g4.13pre-57g1dedcee73`. I can reproduce the issue with this build -- great (or, not great. but, you know.)

So I paused it in the debugger and found that it's stuck in a loop in MapLoader::FixHoles().
The loop it gets stuck in is here:
https://github.com/ZDoom/gzdoom/blob/ma ... o.cpp#L833

I traced through it a few times. What happens is that `bogussegs.Size() > 0` but in this for loop over `bogussegs`, nothing happens and `foundsome` is always false.

In that case, there is this if block:
https://github.com/ZDoom/gzdoom/blob/ma ... o.cpp#L862

I'm not completely clear on what's going on here, what this comparison is, but the inner if statement's condition is false and so we do not `segloop-Clear()`.

But in that case, when `((*segloop)[0]->v1 == segloop->Last()->v2)` after `foundsome` is false, means that nothing will happen next time we repeat the while loop, either. and we will loop here forever repeating the for loop, not finding any, and not clearing segloop either. so there is no way of a bogusseg to be deleted, and thus the while loop never exits.

As an experiment to see what would happen, I removed the inner if statement

Code: Select all

	if (!foundsome)
	{
		segloop->Clear();
	}
and in this case the map loads as expected.

So that's why I think it's probably a bug -- because somehow there should be a way out of this loop, no matter what the map geometry.

Attachment size is limited to 52KB or I'd post an example. I have a 589K ZIP of a WAD that I can share by email or something, DM me.

Return to “Bugs [GZDoom]”