What is causing this crash when encoding lightmaps?

Hi there,

We’re under a lot of pressure to get something done asap, but we’ve run into a nasty issue where Unreal4 is crashing right near the end of a very intensive lighting procedure, apparently during the lightmap encoding process.

While it might be something we did wrong, the engine certainly isn’t making it clear what it is and because the crash happens at the end of compiling lighting, this would be an extremely time intensive thing to figure out without help.

Call stack follows:

MachineId:57F60DF5478BDA0901A0509259C63B87
EpicAccountId:2ff5e32898f54806ad9f63e9b229fd65

Unknown exception - code 00000001 (first/second chance not available)

Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.7\Engine\Source\Runtime\RenderCore\Private\RenderResource.cpp] [Line: 118]
A FRenderResource was deleted without being released first!

KERNELBASE + 109229 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\misc\outputdevice.cpp:531]
UE4Editor_RenderCore!FRenderResource::~FRenderResource() + 121 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\rendercore\private\renderresource.cpp:120]
UE4Editor_Engine!FColorVertexBuffer::`vector deleting destructor’() + 127 bytes
UE4Editor_Engine!FStaticMeshComponentLODInfo::CleanUp() + 401 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\staticmeshcomponent.cpp:1802]
UE4Editor_Engine!TArray::RemoveAt() + 90 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\containers\array.h:1430]
UE4Editor_Engine!UStaticMeshComponent::SetLODDataCount() + 123 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\staticmeshrender.cpp:148]
UE4Editor_Engine!FStaticMeshStaticLightingTextureMapping::Apply() + 429 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\staticmeshlight.cpp:221]
UE4Editor_UnrealEd!FLightmassProcessor::ProcessMapping() + 288 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\lightmass\lightmass.cpp:3666]
UE4Editor_UnrealEd!FLightmassProcessor::ProcessAvailableMappings() + 304 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\lightmass\lightmass.cpp:3703]
UE4Editor_UnrealEd!FLightmassProcessor::CompleteRun() + 192 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\lightmass\lightmass.cpp:2871]
UE4Editor_UnrealEd!FStaticLightingSystem::FinishLightmassProcess() + 883 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\staticlightingsystem\staticlightingsystem.cpp:1908]
UE4Editor_UnrealEd!FStaticLightingManager::ProcessLightingData() + 234 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\staticlightingsystem\staticlightingsystem.cpp:118]
UE4Editor_UnrealEd!FStaticLightingSystem::UpdateLightingBuild() + 2008 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\staticlightingsystem\staticlightingsystem.cpp:2056]
UE4Editor_UnrealEd!UEditorEngine::UpdateBuildLighting() + 100 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\staticlightingsystem\staticlightingsystem.cpp:2150]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() + 177 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\unrealedengine.cpp:388]
UE4Editor!FEngineLoop::Tick() + 4179 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:2257]
UE4Editor!GuardedMain() + 1404 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

Hi GreatBird,

Would you be able to upload your Log as well (Project Folder > Saved > Logs)?

I’ve searched through our bug database but have not found any crashes similar to this one. However, I did find two answerHub post that the users were able to resolve their issue. These may be a help in the interim while I’m looking into this and trying to reproduce.

This user gave more details, which I am trying to reproduce this on my end.

The other, while not as much information, the user found that deleting some asset and rebuilding was able to get this resolved in their case.

These do not solve the underlying issue for the crash though.

Thanks for your help and patience while I look into this.

Tim

The assert is happening because FStaticMeshComponentLODInfo is being deleted directly but it has rendering resources, which need to be released first. From looking at the code, this will only happen on a mesh with LODs that has painted vertex colors. There might be some more criteria.

Here’s a potential fix - I haven’t tested it yet because I haven’t repro’ed the crash successfully yet.

In UStaticMeshComponent::SetLODDataCount, add the portion just before the RemoveAt call

    if (MaxSize < (uint32)LODData.Num())
{
	// FStaticMeshComponentLODInfo can't be deleted directly as it has rendering resources
	for (int32 Index = MaxSize; Index < LODData.Num(); Index++)
	{
		LODData[Index].ReleaseOverrideVertexColorsAndBlock();
	}

	// call destructors
	LODData.RemoveAt(MaxSize, LODData.Num() - MaxSize);
}

Let me know if that fixes it, and I will check it in here.

This was the fix, and is now checked in

Change 2541394 by .Wright@DWRIGHT-G5038-UE4_CODE2 on 2015/05/07 14:39:22
Fix for crash importing lighting with static meshes with LODs that have been vertex painted

Here is the GitHub link for the CL. https://github.com/EpicGames/UnrealEngine/commit/5128849f913deb08a1f9dcebc30d6887d7e33f55