Description

In a networked PIE session, when the server has applied a programmatically constructed GameplayEffect that has duration policy = Infinite or HasDuration, this results in a client crash when the client activates a GAS debug HUD with console command

AbilitySystem.DebugAttribute <Attribute> 

This crash happens due to the AbilitySystemComponent's ActiveGameplayEffects containing FActiveGameplayEffect entries with Spec.Def == null but 

FActiveGameplayEffectsContainer::GetActiveGameplayEffectDataByAttribute()

doesn't take this into account.

Steps to Reproduce

Given a character class AMyCharacter, with a UAbilitySystemComponent that has an attribute set UMyAttributeSet with Damage attribute:

  • Make this the pawn class of the game mode.
  • Server-side, apply a programmatically constructed UGameplayEffect like this:
void AMyCharacter::BeginPlay()
{
   Super::BeginPlay();
   if (HasAuthority())
   {
      UGameplayEffect* GE = NewObject<UGameplayEffect>();
      GE->Modifiers.SetNum(1);
      GE->Modifiers[0].ModifierMagnitude = FScalableFloat(3.0f);
      GE->Modifiers[0].ModifierOp = EGameplayModOp::Additive;
      GE->Modifiers[0].Attribute = MyAttributeSet->GetDamageAttribute();
      GE->DurationPolicy = EGameplayEffectDurationType::Infinite;
      AbilitySystemComp->ApplyGameplayEffectToSelf(GE, 0.0f, AbilitySystemComp->MakeEffectContext());
   }
}
  • Start a server + client PIE session. Ensure you're controlling a AMyCharacter and that the GE has been added server-side.
  • On the client, execute the console command

 

AbilitySystem.DebugAttribute Damage

 

  • Observe a crash with the attached callstack due to access of Spec.Def which is null.
  • Expected: No crash
Callstack

FActiveGameplayEffectsContainer::GetActiveGameplayEffectDataByAttribute(TMultiMap<FGameplayAttribute,FActiveGameplayEffectsContainer::DebugExecutedGameplayEffectData,FDefaultSetAllocator,TDefaultMapHashableKeyFuncs<FGameplayAttribute,FActiveGameplayEffectsContainer::DebugExecutedGameplayEffectData,1> > &) GameplayEffect.cpp:4939
UAbilitySystemDebugHUDExtension_Attributes::GetDebugStrings(const AActor *,const UAbilitySystemComponent *,TArray<FString,TSizedDefaultAllocator<32> > &) AbilitySystemDebugHUD.cpp:169
AAbilitySystemDebugHUD::DrawAbilityDebugInfo(UCanvas *,APlayerController *) AbilitySystemDebugHUD.cpp:598
AAbilitySystemDebugHUD::DrawDebugHUD(UCanvas *,APlayerController *) AbilitySystemDebugHUD.cpp:402
[Inlined] Invoke(void (AAbilitySystemDebugHUD::*)(UCanvas *, APlayerController *),AAbilitySystemDebugHUD *&,UCanvas *&&,APlayerController *&&) Invoke.h:66
[Inlined] UE::Core::Private::Tuple::TTupleBase<TIntegerSequence<unsigned int> >::ApplyAfter(void (AAbilitySystemDebugHUD::*&)(UCanvas *, APlayerController *),AAbilitySystemDebugHUD *&,UCanvas *&&,APlayerController *&&) Tuple.h:311
TBaseUObjectMethodDelegateInstance<0,AAbilitySystemDebugHUD,void __cdecl(UCanvas *,APlayerController *),FDefaultDelegateUserPolicy>::ExecuteIfSafe(UCanvas *,APlayerController *) DelegateInstancesImpl.h:665
[Inlined] TMulticastDelegateBase<FDefaultDelegateUserPolicy>::Broadcast(UCanvas *,APlayerController *) MulticastDelegateBase.h:254
[Inlined] TMulticastDelegate<void __cdecl(UCanvas *,APlayerController *),FDefaultDelegateUserPolicy>::Broadcast(UCanvas *,APlayerController *) DelegateSignatureImpl.inl:956
UDebugDrawService::Draw(FEngineShowFlags,UCanvas *) DebugDrawService.cpp:93
UDebugDrawService::Draw(FEngineShowFlags,FViewport *,FSceneView *,FCanvas *,UCanvas *) DebugDrawService.cpp:76
UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1875
FViewport::Draw(bool) UnrealClient.cpp:1852
UEditorEngine::Tick(float,bool) EditorEngine.cpp:2176
UUnrealEdEngine::Tick(float,bool) UnrealEdEngine.cpp:528
FEngineLoop::Tick() LaunchEngineLoop.cpp:5819
[Inlined] EngineTick() Launch.cpp:61
GuardedMain(const wchar_t *) Launch.cpp:190
LaunchWindowsStartup(HINSTANCE__ *,HINSTANCE__ *,char *,int,const wchar_t *) LaunchWindows.cpp:247
WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:298
[Inlined] invoke_main() 0x00007ff72ae09426
__scrt_common_main_seh() 0x00007ff72ae09405
<unknown> 0x00007ffa4c177614
<unknown> 0x00007ffa4e0226a1

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-192371 in the post.

1
Login to Vote

Fixed
ComponentUE - Gameplay - Gameplay Ability System
Affects Versions5.25.3
Target Fix5.4
Fix Commit27305486
Main Commit27305486
CreatedAug 8, 2023
ResolvedAug 23, 2023
UpdatedApr 12, 2024