[4.7.1] Nullpointer crash in UNavigationSystem::OnLevelRemovedFromWorld()

**Engine Version: ** 4.7.1, Launcher Version

Happens Where: In editor with level and sublevel editor tools.

We are getting crashes when opening a second level after modifying/rebuilding navmesh data and save. I’m currently replacing old navmesh data after transitioning from 4.6, by deleting the old data and readding/building the new volumes.

We’re using a persistent level with navmesh and gameplay data, with geometry/art in a sublevel, this is because we’re decoupling art and gameplay data. Note that the levels play just fine and we did not get these crashes in 4.6.

This is where VisualStudio adds a breakpoint when the editor crashes.

In NavigationSystem.cpp:

void UNavigationSystem::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld)
{
	if (InWorld == GetWorld())
	{
		RemoveLevelCollisionFromOctree(InLevel);

		if (InLevel && !InLevel->IsPersistentLevel())
		{
			for (ANavigationData* NavData : NavDataSet)
			{
				NavData->OnStreamingLevelRemoved(InLevel); // <-- BREAKPOINT HERE
			}
		}
	}
}

Reading through the callstack and checking values, I noticed that NavData in the inner loop is being accessed when being NULL. This should be easy to fix by checking IsValid() or if (NavData). See attached file for callstack.link text

Hey Denny,

Thanks for reporting this one. The issue here is we’re not clearing NavDataSet from nulls upon navigation data instances removal in the editor - if we added validity check here it would crash somewhere else since NavDataSet is assumed to not contain nulls.

If this continues to be a problem I suggest loading level, removing old navigation data instances. Saving level and reopening it. That should make that broken bit right.

In the mean time I’ve filed this as an issue to solve.

Cheers,

–mieszko

Thank you Mieszko. I will remove, save and reload level before adding the volumes again. If that does not work, I will try to rebuild paths in-between those steps to get the engine to clear any possible issues.

Thanks again for the educational response. One step closer to understanding the depths of the engine.

No worries. And don’t hesitate to share any feedback!

I think I have tried every combination available of building paths/geometry, removing / adding volumes, saving and opening maps. I still get the same crash. Good thing is that I can build new paths and save the map before crash. In the end it’s just an annoyance that I have to do once with each map, it’s not like we’re loosing work.

This also only happens with maps that I transition from 4.6, so it should be a one time annoyance.

Cheers~

Hi Denny,

I tried to reproduce this using a project created in 4.6.1 with a few simple levels containing navmesh information, then upgraded to 4.7.1 and replaced the navmesh in each level. I did not run into any issues with the project. Is this something that you are only seeing in your own project? Are you seeing this happen with every one of your levels, or only some of them?

The crash happens with all our levels and every time I delete the actors, regenerate navmesh, save and close the map. It would not surprise me if it is the manual delete of the actors that are causing this issue.

Did you remove the navactors as well when trying to replicate the issue? (not only the volume) I did this on our end to ensure that navdata really gets erased, because we had issues with pawns not moving along the navmesh despite it being generated.