UE4.5 crash after running test

Hi,

since UE4.5 update I have a problem when running tests that creates a world and spawns an actor in it. The procedure is following:

  1. Start the editor
  2. Open Session Frontend
  3. Run the test
  4. Close the editor
  5. Crash!

Here is a simple test that will lead to a crash:

IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSpawnActorTest, "Test.SpawnActorTest", EAutomationTestFlags::ATF_Editor)

bool FSpawnActorTest::RunTest(const FString& Parameters)
{
	// Initialize World and WorldContext
	UWorld* World = UWorld::CreateWorld(EWorldType::Game, false);
	FWorldContext &WorldContext = GEngine->CreateNewWorldContext(EWorldType::Game);
	WorldContext.SetCurrentWorld(World);

	FURL URL;
	World->InitializeActorsForPlay(URL);
	World->BeginPlay();

	APointLight* TestActor = World->SpawnActor<APointLight>();
	World->EditorDestroyActor(TestActor, false);

	// Destroy world
	GEngine->DestroyWorldContext(World);
	World->DestroyWorld(false);

	return true;
}

And here the call stack of the exception:

>	UE4Editor-Core.dll!StaticFailDebug(const wchar_t * Error, const char * File, int Line, const wchar_t * Description, bool bIsEnsure) Line 186	C++
 	UE4Editor-Core.dll!FDebug::AssertFailed(const char * Expr, const char * File, int Line, const wchar_t * Format, ...) Line 220	C++
 	UE4Editor-Core.dll!TStaticIndirectArrayThreadSafeRead<FNameEntry,2097152,16384>::GetItemPtr(int Index) Line 306	C++
 	UE4Editor-Core.dll!FName::ToString(FString & Out) Line 743	C++
 	UE4Editor-Core.dll!FName::ToString() Line 737	C++
 	UE4Editor-CoreUObject.dll!UObjectBaseUtility::GetName() Line 199	C++
 	UE4Editor-UnrealEd.dll!FEditorFileUtils::SaveDirtyPackages(const bool bPromptUserToSave, const bool bSaveMapPackages, const bool bSaveContentPackages, const bool bFastSave, const bool bNotifyNoPackagesSaved, bool * bOutPackagesNeededSaving) Line 2529	C++
 	UE4Editor-MainFrame.dll!FMainFrameHandler::CanCloseEditor() Line 207	C++
 	UE4Editor-MainFrame.dll!FMainFrameHandler::CloseRootWindowOverride(const TSharedRef<SWindow,0> & WindowBeingClosed) Line 226	C++
 	UE4Editor-SlateCore.dll!SWindow::RequestDestroyWindow() Line 1020	C++
 	UE4Editor-Slate.dll!SWindowTitleBar::CloseButton_OnClicked() Line 396	C++
 	UE4Editor-Slate.dll!TBaseSPMethodDelegateInstance_RetVal_NoParams<SWindowTitleBar,FReply,0>::Execute() Line 161	C++
 	UE4Editor-Slate.dll!TBaseDelegate_RetVal_NoParams<FReply>::Execute() Line 1058	C++
 	UE4Editor-Slate.dll!SButton::OnMouseButtonUp(const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) Line 188	C++
 	UE4Editor-Slate.dll!FSlateApplication::ProcessMouseButtonUpEvent(FPointerEvent & MouseEvent) Line 3505	C++
 	UE4Editor-Slate.dll!FSlateApplication::OnMouseUp(const EMouseButtons::Type Button) Line 3469	C++
 	UE4Editor-Core.dll!FWindowsApplication::ProcessDeferredMessage(const FDeferredWindowsMessage & DeferredMessage) Line 1346	C++
 	UE4Editor-Core.dll!FWindowsApplication::DeferMessage(TSharedPtr<FWindowsWindow,0> & NativeWindow, HWND__ * InHWnd, unsigned int InMessage, unsigned __int64 InWParam, __int64 InLParam, int MouseX, int MouseY, unsigned int RawInputFlags) Line 1637	C++
 	UE4Editor-Core.dll!FWindowsApplication::ProcessMessage(HWND__ * hwnd, unsigned int msg, unsigned __int64 wParam, __int64 lParam) Line 737	C++
 	UE4Editor-Core.dll!FWindowsApplication::AppWndProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wParam, __int64 lParam) Line 599	C++
 	[External Code]	
 	UE4Editor-Core.dll!FWindowsPlatformMisc::PumpMessages(bool bFromMainLoop) Line 757	C++
 	UE4Editor.exe!FEngineLoop::Tick() Line 2111	C++
 	UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 133	C++
 	UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 190	C++

Interesting: if you click “Play” the game (any game) after having run the tests (4) and before closing the editor (5), the crash will not occur. This behavior is new in 4.5 - it did not happen in 4.4.

Best reagards