Reproducible crash if UE_PLAYER_INPUT_INCLUDE_DEBUG is enabled

In EnhancedPlayerInput.cpp, UEnhancedPlayerInput::EvaluateInputComponentDelegates, the call to UE::Input::FPlayerInputDebugging::BroadcastPlayerInputDelegateExecuted will crash if the delegate execution before it disables/removes the same binding; this removes the FInputActionInstance from ActionInstanceData and causes ActionData->GetSourceAction() to return a dangling pointer.

[Attachment Removed]

Steps to Reproduce
Set up any project where an input’s action unbinds itself.

[Attachment Removed]

Hello! We’re catching up on bug reports, so my apologies for the slow response.

I’m able to reproduce the bug based on your info. It hasn’t been addressed yet in the latest engine source either. I’ll go ahead and discuss with the enhanced input system owner to decide what we’ll do about this.

I’d like to double check something with you. For me, the easiest way to repro is by adding or removing mapping contexts with

FModifyContextOptions Options;
Options.bForceImmediately = true;

which causes the mapping contexts to be updated synchronously instead of at end-of-frame. That’s what causes the FInputActionInstance* ActionData to be reallocated. Are you also using that option in your repro case? Just making sure we’ll cover all repro cases.

[Attachment Removed]

Yes, I believe so.

[Attachment Removed]

Alright, then my repro matches your repro conditions. The enhanced input system owner will be working to address this crash in the engine.

In the meantime, are you currently still impacted by this crashs or have you already implemented a workaround locally?

[Attachment Removed]

Yeah our workaround is changing

#if UE_PLAYER_INPUT_INCLUDE_DEBUG
  UE::Input::FPlayerInputDebugging::BroadcastPlayerInputDelegateExecuted(
    this,

to

#if UE_PLAYER_INPUT_INCLUDE_DEBUG
  // ActionData may not be valid if Delegate->Execute messes with the input mappings
  ActionData = const_cast<FInputActionInstance*>(FindActionInstanceData(DelegateAction));
  if (ActionData)
  {
    UE::Input::FPlayerInputDebugging::BroadcastPlayerInputDelegateExecuted(
      this,

under the assumption that the second FindActionInstanceData will return the correct result. That being said, thinking about it now, it might make the debug function return incorrect data. (We don’t use it so we wouldn’t have noticed.)

[Attachment Removed]

Hey again, a small update on our side. The issue I created based on your report is live at UE-398245.

Your workaround sounds good. The page for UE-398245 will reflect when we’ve addressed this crash in engine code, but it’s targeting UE6 so don’t expect it soon.

I’ll close this case. Thank you for reporting the crash!

[Attachment Removed]