We are using Unreal Engine 4.22.3 and the Playfab Blueprint API. We are occasionally getting a crash that happens when requesting group data from playfab. This happens on a timer every 10 seconds to ensure the most up to date information is available since we don’t have a push notification service. The engine usually succeeds with this but sometimes crashes stating that the custom data passed to the OnSuccess delegate (to indicate the Group ID that the invite is for) is NULL.
Looking it up, I found that others had this problem on the playfab community portal as well and their issue was that the object was garbage collected too quickly. After confirming that the returned custom data was a new object, I decided to store my variables in an array until I dispatch them, then remove them from the array to allow for garbage collection after dispatch.
The program eventually crashes. I can do that easier by spamming the refresh of the invites page and in turn triggering the request. It is however inconsistent. The error itself is usually in:
Exception thrown at 0x0000000000000000 in UE4Editor-Win64-DebugGame.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
void UFunction::Invoke(UObject* Obj, FFrame& Stack, RESULT_DECL)
{
checkSlow(Func);
UClass* OuterClass = (UClass*)GetOuter();
if (OuterClass->IsChildOf(UInterface::StaticClass()))
{
Obj = (UObject*)Obj->GetInterfaceAddress(OuterClass);
}
TGuardValue<UFunction*> NativeFuncGuard(Stack.CurrentNativeFunction, this);
return (*Func)(Obj, Stack, RESULT_PARAM);
}
The Stack in the return shows that custom data is at NULL
Looking through the callstack hasn’t been too enlightening to me. The delegate finds the function to call just fine. Then something breaks.
0000000000000000() Unknown
UE4Editor-CoreUObject.dll!UObject::CallFunction(FFrame & Stack, void * const Z_Param__Result, UFunction * Function) Line 861 C++
[Inline Frame] UE4Editor-CoreUObject.dll!FFrame::Step(UObject *) Line 319 C++
UE4Editor-CoreUObject.dll!UObject::ProcessContextOpcode(FFrame & Stack, void * const Z_Param__Result, bool bCanFailSilently) Line 2314 C++
[Inline Frame] UE4Editor-CoreUObject.dll!FFrame::Step(UObject *) Line 319 C++
UE4Editor-CoreUObject.dll!UObject::execLet(UObject * Context, FFrame & Stack, void * const Z_Param__Result) Line 2100 C++
[Inline Frame] UE4Editor-CoreUObject.dll!FFrame::Step(UObject *) Line 319 C++
UE4Editor-CoreUObject.dll!ProcessLocalScriptFunction(UObject * Context, FFrame & Stack, void * const Z_Param__Result) Line 974 C++
UE4Editor-CoreUObject.dll!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>(UObject * Context, UFunction * Function, FFrame & Stack, void * const Z_Param__Result, void(*)(UObject *, FFrame &, void *) ExecFtor) Line 809 C++
UE4Editor-CoreUObject.dll!ProcessLocalFunction(UObject * Context, UFunction * Fn, FFrame & Stack, void * const Z_Param__Result) Line 1033 C++
[Inline Frame] UE4Editor-CoreUObject.dll!FFrame::Step(UObject *) Line 319 C++
UE4Editor-CoreUObject.dll!ProcessLocalScriptFunction(UObject * Context, FFrame & Stack, void * const Z_Param__Result) Line 974 C++
UE4Editor-CoreUObject.dll!UObject::ProcessInternal(UObject * Context, FFrame & Stack, void * const Z_Param__Result) Line 1058 C++
> UE4Editor-CoreUObject.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Z_Param__Result) Line 4643 C++
UE4Editor-CoreUObject.dll!UObject::ProcessEvent(UFunction * Function, void * Parms) Line 1464 C++
UE4Editor-Engine.dll!AActor::ProcessEvent(UFunction * Function, void * Parameters) Line 769 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!TScriptDelegate<FWeakObjectPtr>::ProcessDelegate<UObject>(void * Parameters) Line 248 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!UPlayFabClientAPI::FDelegateOnSuccessGetSharedGroupData_DelegateWrapper(const TScriptDelegate<FWeakObjectPtr> & DelegateOnSuccessGetSharedGroupData, FClientGetSharedGroupDataResult result, UObject * customData) Line 2163 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!UPlayFabClientAPI::HelperGetSharedGroupData(FPlayFabBaseModel response, UObject * customData, bool successful) Line 8374 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!UPlayFabClientAPI::execHelperGetSharedGroupData(UObject * Context, FFrame & Stack, void * const Z_Param__Result) Line 29 C++
UE4Editor-CoreUObject.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Z_Param__Result) Line 4643 C++
UE4Editor-CoreUObject.dll!UObject::ProcessEvent(UFunction * Function, void * Parms) Line 1464 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!TScriptDelegate<FWeakObjectPtr>::ProcessDelegate<UObject>(void * Parameters) Line 248 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!TMulticastScriptDelegate<FWeakObjectPtr>::ProcessMulticastDelegate<UObject>(void * Parameters) Line 494 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!FOnPlayFabClientRequestCompleted_DelegateWrapper(const TMulticastScriptDelegate<FWeakObjectPtr> & OnPlayFabClientRequestCompleted, FPlayFabBaseModel response, UObject * customData, bool successful) Line 24 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!UPlayFabClientAPI::OnProcessRequestComplete(TSharedPtr<IHttpRequest,0> Request, TSharedPtr<IHttpResponse,1> Response, bool bWasSuccessful) Line 9219 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!TMemberFunctionCaller<UPlayFabClientAPI,void (__cdecl UPlayFabClientAPI::*)(TSharedPtr<IHttpRequest,0>,TSharedPtr<IHttpResponse,1>,bool)>::operator()<TSharedPtr<IHttpRequest,0> &,TSharedPtr<IHttpResponse,1> &,bool &>(TSharedPtr<IHttpRequest,0> & <Args_0>, TSharedPtr<IHttpResponse,1> & <Args_1>, bool & <Args_2>) Line 157 C++
UE4Editor-PlayFab-Win64-DebugGame.dll!TBaseUObjectMethodDelegateInstance<0,UPlayFabClientAPI,void __cdecl(TSharedPtr<IHttpRequest,0>,TSharedPtr<IHttpResponse,1>,bool)>::ExecuteIfSafe(TSharedPtr<IHttpRequest,0> <Params_0>, TSharedPtr<IHttpResponse,1> <Params_1>, bool <Params_2>) Line 677 C++
UE4Editor-HTTP.dll!TBaseDelegate<void,TSharedPtr<IHttpRequest,0>,TSharedPtr<IHttpResponse,1>,bool>::ExecuteIfBound(TSharedPtr<IHttpRequest,0> <Params_0>, TSharedPtr<IHttpResponse,1> <Params_1>, bool <Params_2>) Line 648 C++
UE4Editor-HTTP.dll!FCurlHttpRequest::FinishedRequest() Line 1092 C++
UE4Editor-HTTP.dll!FHttpManager::Tick(float DeltaSeconds) Line 199 C++
[Inline Frame] UE4Editor-Core.dll!TBaseDelegate<bool,float>::Execute(float) Line 561 C++
[Inline Frame] UE4Editor-Core.dll!FTicker::FElement::Fire(float) Line 127 C++
UE4Editor-Core.dll!FTicker::Tick(float DeltaTime) Line 95 C++
UE4Editor-Win64-DebugGame.exe!FEngineLoop::Tick() Line 4167 C++
[Inline Frame] UE4Editor-Win64-DebugGame.exe!EngineTick() Line 62 C++
UE4Editor-Win64-DebugGame.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 168 C++
UE4Editor-Win64-DebugGame.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 261 C++
[External Code]
My coworker believes that maybe there is a issue with how we are creating the delegates. Possibly hitting a ceiling to how many we can have, or how frequently we can call them. I’m open to any interpretation or guidance.