# Mirroring the same effect class is causing a stack overflow

**URL:** <https://forums.unrealengine.com/t/mirroring-the-same-effect-class-is-causing-a-stack-overflow/2726482>\
**Category:** Programming & Scripting\
**Tags:** Ability-System, unreal-engine, question, CPP\
**Created:** [June 5, 2026, 3:01pm UTC](https://forums.unrealengine.com/t/mirroring-the-same-effect-class-is-causing-a-stack-overflow/2726482 "2026-06-05T15:01:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennur\_1206](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bennur\_1206](https://forums.unrealengine.com/u/bennur_1206)\
**Post date:** [June 5, 2026, 3:01pm UTC](https://forums.unrealengine.com/t/mirroring-the-same-effect-class-is-causing-a-stack-overflow/2726482/1 "2026-06-05T15:01:50Z")

</div>

When I try to apply parry effect back to the attacker in an attribute set - I am technically mirroring the same melee effect class - I get a stack overflow at the line of ApplyEffectToTarget and then access violation error:

```cpp
void Uattribute_set_combat::apply_parry_effect_back_to_source(
	const FGameplayEffectModCallbackData & Data
) const
{
	UAbilitySystemComponent * asc_ = GetOwningAbilitySystemComponent();
	if ( !asc_ ) return;

	FGameplayEffectContextHandle effect_context_handle_ = asc_->MakeEffectContext();

	UAbilitySystemComponent * attacker_asc_ =
		Data.EffectSpec.GetEffectContext().GetOriginalInstigatorAbilitySystemComponent();
	if ( !attacker_asc_ )
	{
		GEngine->AddOnScreenDebugMessage(
			-1,
			5.f,
			FColor::Red,
			FString::Printf(
				TEXT("Attacker ASC not found")
			)
		);
		return;
	}

	FGameplayEffectSpecHandle effect_spec_handle_ = asc_->MakeOutgoingSpec(
		Data.EffectSpec.Def->GetClass(),
		1.f,
		effect_context_handle_
	);

	FGameplayTag tag_parry_ = FGameplayTag::RequestGameplayTag("combat.action.parry");

	effect_spec_handle_.Data->DynamicGrantedTags.AddTag(tag_parry_);

	GEngine->AddOnScreenDebugMessage(
		-1,
		5.f,
		FColor::Black,
		FString::Printf(
			TEXT("%s is PARRYING %s"),
			*asc_->GetOwnerActor()->GetName(),
			*attacker_asc_->GetOwnerActor()->GetName()
		)
	);

	// ERROR: Backing attribute causing stack overflow?
	// asc_->ApplyGameplayEffectSpecToTarget(
	// *(effect_spec_handle_.Data),
	// attacker_asc_,
	// FPredictionKey()
	// );

}

```

This is how I am detecting parry, in the same attribute set combat:

```cpp
bool Uattribute_set_combat::PreGameplayEffectExecute(FGameplayEffectModCallbackData & Data){
// If not operated on parry, proceed with ABCDreturn !

operate_on_parry(Data);

}

bool Uattribute_set_combat::operate_on_parry(FGameplayEffectModCallbackData & Data) const{

if ( Data.EvaluatedData.Attribute != Getincoming_damageAttribute() )

return false;

if ( !validate_successfully_parried() )
	return false;

// Mirror effect back to source
apply_parry_effect_back_to_source(Data);

return true;

}

const bool Uattribute_set_combat::validate_successfully_parried() const{
// combat_component->validate_is_facing_hit_result()

FGameplayTag tag_parry_ = FGameplayTag::RequestGameplayTag("combat.action.parry");
if ( UAbilitySystemComponent * asc_ = GetOwningAbilitySystemComponent() )
	return ( asc_->HasMatchingGameplayTag(tag_parry_) );

return false;

}

```

To give more context:  
I have 2 attributes in the same attribute-set combat:

- incoming\_damage - outgoing\_damage

The melee effect overrides target’s incoming damage with its own outgoing damage (say -50).

The incoming damage validates parry, block, and it’s own damage.

So I am able to damage my own health - factored by defense during block.

I do not seem to be able to mirror the same melee-effect class back to the attacker.

Why? How to resolve?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![bennur\_1206](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bennur\_1206](https://forums.unrealengine.com/u/bennur_1206)\
**Post date:** [June 5, 2026, 6:22pm UTC](https://forums.unrealengine.com/t/mirroring-the-same-effect-class-is-causing-a-stack-overflow/2726482/2 "2026-06-05T18:22:11Z")

</div>

Never mind, I figured it out.  
Even the attacker had a parry window - GameplayTag parry,  
And the same effect was being processed in Pre-Gameplay-Effect-Execute.
