Stack around the variable 'Object' was corrupted

We use Unreal Engine (4.5.1, source build) and get error on “Debug” build:

Run-Time Check Failure #2 - Stack around the variable 'Object' was corrupted.
>	UE4Editor-Engine-Win64-Debug.dll!UKismetSystemLibrary::execIsValid(FFrame & Stack, void * const Result) Line 62	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Result) Line 3676	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::CallFunction(FFrame & Stack, void * const Result, UFunction * Function) Line 395	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::execFinalFunction(FFrame & Stack, void * const Result) Line 1479	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!FFrame::Step(UObject * Context, void * const Result) Line 126	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::ProcessContextOpcode(FFrame & Stack, void * const Result, bool bCanFailSilently) Line 1400	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::execContext(FFrame & Stack, void * const Result) Line 1377	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!FFrame::Step(UObject * Context, void * const Result) Line 126	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::execLetBool(FFrame & Stack, void * const Result) Line 1320	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!FFrame::Step(UObject * Context, void * const Result) Line 126	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::ProcessInternal(FFrame & Stack, void * const Result) Line 612	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::CallFunction(FFrame & Stack, void * const Result, UFunction * Function) Line 507	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::execVirtualFunction(FFrame & Stack, void * const Result) Line 1472	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!FFrame::Step(UObject * Context, void * const Result) Line 126	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::ProcessInternal(FFrame & Stack, void * const Result) Line 612	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Result) Line 3676	C++
 	UE4Editor-CoreUObject-Win64-Debug.dll!UObject::ProcessEvent(UFunction * Function, void * Parms) Line 900	C++
 	UE4Editor-Engine-Win64-Debug.dll!AActor::ProcessEvent(UFunction * Function, void * Parameters) Line 540	C++
 	UE4Editor-Engine-Win64-Debug.dll!AActor::ReceiveBeginPlay() Line 1035	C++
 	UE4Editor-Engine-Win64-Debug.dll!AActor::BeginPlay() Line 2270	C++
 	UE4Editor-Engine-Win64-Debug.dll!AWorldSettings::NotifyBeginPlay() Line 127	C++
 	UE4Editor-Engine-Win64-Debug.dll!AGameMode::HandleMatchHasStarted() Line 592	C++
 	UE4Editor-Engine-Win64-Debug.dll!AGameMode::SetMatchState(FName NewState) Line 701	C++
 	UE4Editor-Engine-Win64-Debug.dll!AGameMode::StartMatch() Line 569	C++
 	UE4Editor-Engine-Win64-Debug.dll!AGameMode::StartPlay() Line 518	C++
 	UE4Editor-Engine-Win64-Debug.dll!UWorld::BeginPlay() Line 2896	C++
 	UE4Editor-Engine-Win64-Debug.dll!UGameInstance::StartPIEGameInstance(ULocalPlayer * LocalPlayer, bool bInSimulateInEditor, bool bAnyBlueprintErrors, bool bStartInSpectatorMode) Line 226	C++
 	UE4Editor-UnrealEd-Win64-Debug.dll!UEditorEngine::CreatePIEGameInstance() Line 2524	C++
 	UE4Editor-UnrealEd-Win64-Debug.dll!UEditorEngine::PlayInEditor() Line 1937	C++
 	UE4Editor-UnrealEd-Win64-Debug.dll!UEditorEngine::StartQueuedPlayMapRequest() Line 837	C++
 	UE4Editor-UnrealEd-Win64-Debug.dll!UEditorEngine::Tick() Line 1121	C++
 	UE4Editor-UnrealEd-Win64-Debug.dll!UUnrealEdEngine::Tick() Line 278	C++
 	UE4Editor-Win64-Debug.exe!FEngineLoop::Tick() Line 2129	C++
 	UE4Editor-Win64-Debug.exe!EngineTick() Line 54	C++
 	UE4Editor-Win64-Debug.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 136	C++
 	UE4Editor-Win64-Debug.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 190	C++
 	[External Code]	

We can reproduce this error with steps:

  1. open project: IfaceBug.uproject (this is a minimal project for reproduce this bug);
  2. press “Play” button.

Hi ,

I downloaded and unzipped the project file you provided, then associated it with the 4.5.1 version of the Engine that I have built from source code. When I opened the project and clicked Play, nothing unexpected happened. Should this issue occur immediately, and does it happen for you every time you play the project?

This issue occur immediately after click Play button, but only on “Debug” Editor build. On Development or stock build nothing happened.

There is something new?

Hi ,

I am very sorry for the delay. I lost track of this post.

Could you clarify what you mean when you say that you are using a Debug Editor build? Did you build the Engine using Debug Editor, or are you referring to the project? The test project you provided appears to be a content-only project, so there was no solution for me to open and build in Debug Editor configuration. I added a new Actor code class to the project in order to get a Visual Studio solution, then built the solution in Debug Editor configuration, but still had no problems when starting PIE.

Hi, , I’m coworker. As you can clearly see from dll names in stacktrace, we use “Debug Editor” engine build. I also want to add that this error isn’t 4.5-specific, it also happens on 4.6 and master. The key point in bug reproduction is to build engine itself using debug configuration.

Hi, .

I build a Unreal Engine Editor from github sources (4.5, 4.6, master) on Windows in Visual Studio 2013 with “Debug Editor” configuration.
When I open the project and click Play I immediatly get error: “Run-Time Check Failure #2 - Stack around the variable ‘Object’ was corrupted.”

Initially the problem was discovered on a larger project, but we reproduce it on minimal content-only project: IfaceBug.uproject.

Hi ,

Thank you for the additional clarification. I had previously never had a need to build the Engine using the Debug Editor configuration, so I wasn’t expecting that to be a critical part of the repro of this issue. I have managed to reproduce the crash that you have described, and have entered a report of my findings to have this investigated further (UE-6268). I apologize again for the delay.

I fix this problem: https://github.com/EpicGames/UnrealEngine/pull/680

Cause of problem: user can create blueprint pins between interface (green pin) and object (blue pin).
In this situation Kismet generates opcode for simple copy value. Object in stored as single pointer (8 bytes) but interface is stored as two pointers (16 bytes). And simple copy object to/from interface is corrupting stack.