Editor crash despite of successful compile

Hi, I’ve encountered a weird problem. I’m setting image widget visibility with SetVisibility and setting brush with SetBrushFromTexture. Everything compiles both in VS2015 and Editor. While I’m starting debuging project with VS2015 it works perfectly, image is set as it should, but while I’m starting PIE it crashes when action occurs. I’ve cleaned both Binaries and Intermediate folders, build up again but it didn’t help. Here is my crash report.

Access violation - code c0000005 (first/second chance not available)

UE4Editor_MG20_2168!UInventoryWidget::SetImageAtSlot() [d:\unreal engine 4\mg20\source\mg20\inventorywidget.cpp:21]
UE4Editor_MG20_2168!AMG20Character::AddItem() [d:\unreal engine 4\mg20\source\mg20\mg20character.cpp:134]
UE4Editor_MG20_2168!AMG20Character::AddToInventory() [d:\unreal engine 4\mg20\source\mg20\mg20character.cpp:103]
UE4Editor_MG20_2168!APickupObject::Pickup() [d:\unreal engine 4\mg20\source\mg20\pickupobject.cpp:26]
UE4Editor_MG20_2168!APickupObject::OnClick() [d:\unreal engine 4\mg20\source\mg20\pickupobject.cpp:11]
UE4Editor_MG20_2168!AMG20PlayerController::MouseButtonClicked() [d:\unreal engine 4\mg20\source\mg20\mg20playercontroller.cpp:144]
UE4Editor_Engine!FInputActionUnifiedDelegate::Execute() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\classes\components\inputcomponent.h:181]
UE4Editor_Engine!UPlayerInput::ProcessInputStack() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\userinterface\playerinput.cpp:1211]
UE4Editor_Engine!APlayerController::ProcessPlayerInput() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\playercontroller.cpp:2310]
UE4Editor_Engine!APlayerController::TickPlayerInput() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\playercontroller.cpp:3878]
UE4Editor_Engine!APlayerController::PlayerTick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\playercontroller.cpp:1980]
UE4Editor_Engine!APlayerController::TickActor() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\playercontroller.cpp:3954]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\actor.cpp:110]
UE4Editor_Engine!FTickFunctionTask::DoTask() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\ticktaskmanager.cpp:228]
UE4Editor_Engine!TGraphTask::ExecuteTask() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\public\async\taskgraphinterfaces.h:886]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\private\async\taskgraph.cpp:779]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\private\async\taskgraph.cpp:526]
UE4Editor_Core!FTaskGraphImplementation::WaitUntilTasksComplete() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\private\async\taskgraph.cpp:1534]
UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\ticktaskmanager.cpp:486]
UE4Editor_Engine!FTickTaskManager::RunTickGroup() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\ticktaskmanager.cpp:1373]
UE4Editor_Engine!UWorld::RunTickGroup() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\leveltick.cpp:702]
UE4Editor_Engine!UWorld::Tick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\leveltick.cpp:1187]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\editor\unrealed\private\editorengine.cpp:1356]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\editor\unrealed\private\unrealedengine.cpp:370]
UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\launchengineloop.cpp:2643]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

I’m sure because as I wrote earlier while I’m builiding with Visual Studio it works as it should. I’ve set a breakpoint to double check and it’s not null.

Are you sure that the texture you are settings is not NULL? Because if you SetBrushFromTexture with bMatchSize = true and Texture = NULL it will crash.

Try adding output to make sure all parameters are as you expect.

What do You mean??

I might be reading what you’re saying wrong but it seems that when you run the project from VS it works fine, and from the editor it crashes. When you run from VS the parameters seem fine so you are assuming that when running from the editor they are also fine. However when you run the engine in different ways you might get different results, so it seems worth adding some extra output (UE_LOGs) to print out the values the code is working with at the point of crash (this pointer, Texture pointer, UImage pointer, bMatchsize, anything else).

On a side note I’m confused as to why you can’t debug this. PIE is possible within Visual Studio you just build and launch the DebugGame Editor configuration.

Make sure you do not dereference null-pointers. Pointers are ■■■■■■■, compiler can’t catch it so you have to pay attention

I’ve debugged it in DebugGame Editor mode and it turned out that problem was with TArray holding pointers to my inventory slots. Pointers were not null but there was problem with “access violation reading location”. I’ve moved initialization of TArray from header to source file and it helped.

Physical location of code doesn’t normally make a difference in c++, though in unreal’ case there could be caveats to that given it’s code generation.

With pointers you need to be careful about pointers to UObject derived classes. Rather than using normal pointers you’ll want to make them UPROPERTYs which allows the engine to correctly know when the objects are referenced and when they can be garbage collected.

Glad you’re up and running again!