UE5.1 Editor crash on Lightmass build: Assertion failed in NaniteMaterials.h

Hi,
Working on a UE5.1 project in a large scene with tons of geometry brought in via Datasmith and converted to Nanite. Decided to try out Lightmass, but building lights crashes the engine without fail pretty much instantly after starting the build. Worked fine in another scene with no Nanite meshes.

Here’s the error:

Assertion failed: InStateBucketId < ((1 << 14) - 1) [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Renderer\Private\Nanite\NaniteMaterials.h] [Line: 34]

UnrealEditor_Renderer
UnrealEditor_Renderer
UnrealEditor_Renderer
UnrealEditor_Renderer
UnrealEditor_Renderer
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_RenderCore
UnrealEditor_RenderCore
UnrealEditor_Core
UnrealEditor_Core
kernel32
ntdll

It’s always the same error down to the line.
Here’s the line(s) it references from the source:

inline void SetStateBucketId(int32 InStateBucketId)
	{
		check(InStateBucketId < NANITE_MAX_STATE_BUCKET_ID);
		StateBucketId = InStateBucketId;
	}

The check function is the actual line referenced.

Any ideas?

Additional info:

  • This is an old project that has been brought over from UE4.27 (and older before that).
  • I tried out Lumen before this and still have it enabled.
  • My PC has random issues (most likely faulty RAM) that I will try to diagnose and/or fix further later when some parts I ordered show up, but I don’t think that is the issue here as it worked fine in the other scene and since the error always references NaniteMaterials.h
  • PC Specs: i9 13900K, RTX3080ti, 64GB 6400MHz RAM
  • Editor and project are on a separate non-OS sata-SSD drive