4.11 - C++ Characters crashing on SetSkeletalMesh

Reprosteps:

  • Create a project C++
  • Add a character child class C++
  • Add the Super(PCIP.DoNotCreateDefaultSubobject(TEXT(“CharacterMesh0”))) directive on the constructor.
  • Add 5 class USkeletalMeshComponent * to it and accessors (following the own ACharacter implementation).
  • Create both with the PCIP.CreateOptionalDefaultSubobject(this, NAME) on the constructor and also do the remaining setup (copy from ACharacter constructor used to Mesh).
  • Compile, Start editor.
  • On the editor, create a child BP Class from your new custom Character.
  • Create a Gamemode to use this Character Class as Default Pawn Class
  • Create a function on the Character Class to set the Skeletal Meshes
  • On the level BeginPlay( ) event, get a reference to this character and call the function.

By the few I’ve seen, SpaceBases are empty somehow.

CrashLOG:

Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\BuildFarm\buildmachine_++UE4+Release-4.11\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 785]
Array index out of bounds: 1 from an array of size 0

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\private\misc\outputdevice.cpp:430]
UE4Editor_Engine!USkeletalMeshComponent::SetRootBodyIndex() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\components\skeletalmeshcomponent.cpp:2192]
UE4Editor_Engine!USkeletalMeshComponent::InitArticulated() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\skeletalmeshcomponentphysics.cpp:913]
UE4Editor_Engine!USkeletalMeshComponent::CreatePhysicsState() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\skeletalmeshcomponentphysics.cpp:1474]
UE4Editor_Engine!UActorComponent::ExecuteRegisterEvents() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\components\actorcomponent.cpp:1108]
UE4Editor_Engine!FComponentReregisterContextBase::ReRegister() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\public\componentreregistercontext.h:67]
UE4Editor_Engine!USkinnedMeshComponent::SetSkeletalMesh() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\components\skinnedmeshcomponent.cpp:974]
UE4Editor_Engine!USkeletalMeshComponent::SetSkeletalMesh() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\components\skeletalmeshcomponent.cpp:1400]
UE4Editor_Engine!USkinnedMeshComponent::execSetSkeletalMesh() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\classes\components\skinnedmeshcomponent.h:156]
UE4Editor_CoreUObject!UFunction::Invoke() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\class.cpp:4482]
UE4Editor_CoreUObject!UObject::CallFunction() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:562]
UE4Editor_CoreUObject!UObject::execVirtualFunction() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:2022]
UE4Editor_CoreUObject!UObject::ProcessContextOpcode() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1916]
UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:781]
UE4Editor_CoreUObject!UObject::CallFunction() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:686]
UE4Editor_CoreUObject!UObject::execVirtualFunction() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:2022]
UE4Editor_CoreUObject!UObject::ProcessContextOpcode() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1916]
UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:781]
UE4Editor_CoreUObject!UObject::CallFunction() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:686]
UE4Editor_CoreUObject!UObject::execVirtualFunction() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:2022]
UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:781]
UE4Editor_CoreUObject!UFunction::Invoke() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\class.cpp:4482]
UE4Editor_CoreUObject!UObject::ProcessEvent() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1150]
UE4Editor_Engine!AActor::ProcessEvent() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\actor.cpp:611]
UE4Editor_Engine!AActor::BeginPlay() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\actor.cpp:2907]
UE4Editor_Engine!AWorldSettings::NotifyBeginPlay() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\worldsettings.cpp:148]
UE4Editor_Engine!AGameMode::HandleMatchHasStarted() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\gamemode.cpp:623]
UE4Editor_Engine!AGameMode::SetMatchState() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\gamemode.cpp:739]
UE4Editor_Engine!AGameMode::StartMatch() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\gamemode.cpp:600]
UE4Editor_Engine!UWorld::BeginPlay() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\world.cpp:3159]
UE4Editor_Engine!UGameInstance::StartPIEGameInstance() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\gameinstance.cpp:285]
UE4Editor_UnrealEd!UEditorEngine::CreatePIEGameInstance() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\editor\unrealed\private\playlevel.cpp:3078]
UE4Editor_UnrealEd!UEditorEngine::PlayInEditor() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\editor\unrealed\private\playlevel.cpp:2326]
UE4Editor_UnrealEd!UEditorEngine::StartQueuedPlayMapRequest() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\editor\unrealed\private\playlevel.cpp:1101]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\editor\unrealed\private\editorengine.cpp:1251]
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

Just converted over from 4.9.2 to 4.11 release.

Same issue.

Trying to figure out cause here.

Thought I’d start with physics asset, based on fix from here.

EDIT: Ha, checking 4.9.2 engine source, I’d already modified SetBodyIndex() function to check the index was valid first.

Still no clue on cause though.

Hello,

  • You’ll need to update your code. We haven’t used PCIP for quite a while.
  • Could you explain why you are using DoNotCreateDefaultSubobject?
  • Could you please provide the code that you are using when you are experiencing this crash?

About “update”, the code worked until 4.10.3, without any problem, but I’ll update as you told and see if this will fix the issue.

ACharacter has a “Mesh” named component that works pretty well on a generic context, but that can confuse my class users where I’m working with 5 components (Head, Chest, Legs, Feet and Hands) So, HeadMSH, LegsMSH are names that fits a lot better on the class design.

Yes, I could “rename” the original Mesh component variable, but to this I would need to rename this component on the “engine” ACharacter code (and need to get a custom build to every update) so, your engineer that designed the DoNotCreate directive was really smart on allow us to “kill” an unused component on Actor construction.

I have shared my modular character creation class on the forum, you can watch the code and usage here:
Modular Character Tutorial

I have changed few things, as TSubObjPtr to direct class UskeletalMeshComponent* following updates, but the remaining still the same and worked until I tried update the project to 4.11.

Additional Info:

  • Checking my last version PCIP is a
    FObjectInitializer, I just kept the
    variable name to “write less”, but I
    did changed to ObjectInitializer
    without any change on the crash.

  • Checking the 4.11 ACharacter class I
    have seen that “Mesh” is now
    referenced on a lot of methods
    (FindComponentByClass,
    PostInitialize, Possessed,
    Unpossessed, GetRootMotionAnim) so I
    thought about make a compile
    “without” the donotcreate directive -
    Crash stills.

  • I have tried to “override” the
    methods that references Mesh
    directly, but some can’t be overriden
    (GetRootMotionAnim is not detected on
    parent classes, the own GetMesh( ) if
    overridable would easily “redirect”
    the return to one of my components
    (the root animated one) and ease a
    transition.

  • One detail that got my attention was
    that keeping “exactly” my old code
    and calling SetSkeletalMesh just on
    the headMSHcomponent (the first
    created and declared) doesn’t crash
    the game neither the editor, but on
    try setting any further added
    component causes the crash.

  • Regarding the above issue, until
    seting “the same asset” to them still
    causes the crash.

  • Trying to make the CharacterClass
    (regarding components) through
    Blueprints (getting a ACharacter as
    parent and adding a
    skeletalmeshcomponent) works
    perfectly and doesn’t crash the game
    or the engine. This is getting me
    crazy since all my components are
    declared and created in the same way
    shown on the original ACharacter
    class code.

The “shorter” path would be create a child from SkeletalMeshComponent and fix the crashing assert trying to override SetRootBodyIndex( ), but the simple curiosity in know what is going on and the unknown future consequences on maybe being bypassing a serious bug is driving me crazy.

Any help will be really appreciated.

The fix I mentioned and showed here has made its way into the 4.11.1 hotfix.

So all is right in the world… or something :slight_smile: