Description

Using NewObject inside PostInitProperties and creating a BP of the class will cause the editor to crash on PIE if the BP is is set in gamemode defaults

Steps to Reproduce
  1. Open UE4Editor (any project)
  2. Add code to project based on pawn (MyPawn)
  3. In MyPawn.h add the following:
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test)
    		UCapsuleComponent* PlayerComponent;
    
    	virtual void PostInitProperties() override;
    
  4. In MyPawn.cpp add the following:
    void AMyPawn::PostInitProperties()
    {
    	Super::PostInitProperties();
    
    	PlayerComponent = NewObject<UCapsuleComponent>(this);
    	PlayerComponent->AttachTo(RootComponent);
    }
    
  5. Compile
  6. In the editor, create a BP based on MyPawn (MyPawnBP) and Gamemode (NewGameModeBP)
  7. In NewGameModeBP set the default pawn to MyPawnBP
  8. PIE

Result:
The editor crashes after clicking Play button

Callstack
MachineId:9FA88CA44B7C623122B0039D6C8BA1B0
EpicAccountId:c807849e05a0413d99e379f2802cae9c

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

""

UE4Editor_Engine!UWorld::EncroachingBlockingGeometry() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\levelactor.cpp:987]
UE4Editor_Engine!AGameMode::ChoosePlayerStart_Implementation() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\gamemode.cpp:1455]
UE4Editor_Engine!AGameMode::execChoosePlayerStart() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\classes\gameframework\gamemode.h:67]
UE4Editor_CoreUObject!UFunction::Invoke() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\class.cpp:4195]
UE4Editor_CoreUObject!UObject::ProcessEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1046]
UE4Editor_Engine!AActor::ProcessEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\actor.cpp:580]
UE4Editor_Engine!AGameMode::ChoosePlayerStart() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\intermediate\build\win64\ue4editor\inc\engine\engine.generated.1.cpp:4557]
UE4Editor_Engine!AGameMode::FindPlayerStart_Implementation() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\gamemode.cpp:379]
UE4Editor_Engine!AGameMode::execFindPlayerStart() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\classes\gameframework\gamemode.h:67]
UE4Editor_CoreUObject!UFunction::Invoke() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\class.cpp:4195]
UE4Editor_CoreUObject!UObject::ProcessEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1046]
UE4Editor_Engine!AActor::ProcessEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\actor.cpp:580]
UE4Editor_Engine!AGameMode::FindPlayerStart() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\intermediate\build\win64\ue4editor\inc\engine\engine.generated.1.cpp:4565]
UE4Editor_Engine!AGameMode::InitNewPlayer() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\gamemode.cpp:1016]
UE4Editor_Engine!AGameMode::Login() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\gamemode.cpp:1057]
UE4Editor_Engine!UWorld::SpawnPlayActor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\levelactor.cpp:665]
UE4Editor_Engine!ULocalPlayer::SpawnPlayActor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\localplayer.cpp:219]
UE4Editor_Engine!UGameInstance::StartPIEGameInstance() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\gameinstance.cpp:253]
UE4Editor_UnrealEd!UEditorEngine::CreatePIEGameInstance() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\playlevel.cpp:3137]
UE4Editor_UnrealEd!UEditorEngine::PlayInEditor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\playlevel.cpp:2385]
UE4Editor_UnrealEd!UEditorEngine::StartQueuedPlayMapRequest() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\playlevel.cpp:1066]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\editorengine.cpp:1244]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\unrealedengine.cpp:366]
UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launchengineloop.cpp:2428]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

0
Login to Vote

Cannot Reproduce
ComponentUE - Gameplay - Blueprint
Affects Versions4.9.2
Target Fix4.13
CreatedOct 23, 2015
ResolvedMay 16, 2016
UpdatedApr 27, 2018
View Jira Issue