It’s me again,
I dived deeper into the issue with my code and found out that the crash is not coming from DBNetworkListener::setCurrentHandler. Instead it’s coming from DBNetworkListener::onStatusChanged. What I did was (my first real
) debugging in VS and adding some checks to the code.
I got inspired by a thread an answerhub (Crash: Multi-threading timing issue- rendering while shutting down - Programming & Scripting - Epic Developer Community Forums) which leads me to the point that an UObject pointer can pass a simple check:
by RAMA
It appears that the call to DBNetworkListener::setCurrentHandler passes all checks:
void DBNetworkListener::setCurrentHandler(UDBNetworkBaseHandler* handler)
{
if (handler && handler->IsValidLowLevel())
{
FString HandlerName;
handler->GetName(HandlerName);
FString HandlerClass = handler->GetFullName();
UE_LOG(DBNet, Error, TEXT("DBNetworkListener: Handler got: %s of type: %s."), *HandlerName, *HandlerClass);
UDBNetworkBaseHandler* currentHandler = handler;
FString CurrentHandlerName;
FString CurrentHandlerClass = currentHandler->GetFullName();
currentHandler->GetName(CurrentHandlerName);
UE_LOG(DBNet, Error, TEXT("DBNetworkListener: Handler got: %s of type: %s."), *CurrentHandlerName, *CurrentHandlerClass);
}
}
In the Logs I see the corresponding entries:
[2015.08.19-14.40.15:026][843]DBNet:Error: DBLoginHandler: Handler got: DBLoginHandler_0 of type: DBLoginHandler /Game/Maps/UEDPIE_0_LoginMap.LoginMap:PersistentLevel.DBLoginController_0.DBLoginHandler_0.
[2015.08.19-14.40.15:027][843]DBNet:Warning: DBNetworkClient: PhotonSetCurrentHandler called and set to: DBLoginHandler_0.
Function: DBNetworkListener::setCurrentHandler(UDBNetworkBaseHandler *), Thread: 0x45C Main Thread, UE4Editor-DragonBorn-Win64-DebugGame.dll!DBNetworkListener::setCurrentHandler
UE4Editor-DragonBorn-Win64-DebugGame.dll!UDBNetworkClient::PhotonSetCurrentHandler
UE4Editor-DragonBorn-Win64-DebugGame.dll!UDBLoginHandler::InitializeComponent
UE4Editor-Engine.dll!UActorComponent::RegisterComponentWithWorld
UE4Editor-Engine.dll!UActorComponent::RegisterComponent
UE4Editor-DragonBorn-Win64-DebugGame.dll!ADBGameMode::BeginPlay
UE4Editor-Engine.dll!AWorldSettings::NotifyBeginPlay
UE4Editor-Engine.dll!AGameMode::HandleMatchHasStarted
UE4Editor-Engine.dll!AGameMode::SetMatchState
UE4Editor-Engine.dll!AGameMode::StartMatch
UE4Editor-Engine.dll!UWorld::BeginPlay
UE4Editor-Engine.dll!UGameInstance::StartPIEGameInstance
UE4Editor-UnrealEd.dll!UEditorEngine::CreatePIEGameInstance
UE4Editor-UnrealEd.dll!UEditorEngine::PlayInEditor
UE4Editor-UnrealEd.dll!UEditorEngine::StartQueuedPlayMapRequest
UE4Editor-UnrealEd.dll!UEditorEngine::Tick
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick
UE4Editor.exe!FEngineLoop::Tick
UE4Editor.exe!GuardedMain
UE4Editor.exe!WinMain
UE4Editor.exe!__tmainCRTStartup
kernel32.dll!BaseThreadInitThunk
ntdll.dll!RtlUserThreadStart
, UDBNetworkClient::PhotonSetCurrentHandler
[2015.08.19-14.40.15:481][843]DBNet:Error: DBNetworkListener: Handler got: DBLoginHandler_0 of type: DBLoginHandler /Game/Maps/UEDPIE_0_LoginMap.LoginMap:PersistentLevel.DBLoginController_0.DBLoginHandler_0.
[2015.08.19-14.40.15:482][843]DBNet:Error: DBNetworkListener: Handler got: DBLoginHandler_0 of type: DBLoginHandler /Game/Maps/UEDPIE_0_LoginMap.LoginMap:PersistentLevel.DBLoginController_0.DBLoginHandler_0.
[2015.08.19-14.40.15:483][843]DBNet:Warning: DBLoginController: BeginPlay()
[2015.08.19-14.40.15:484][843]DBNet:Warning: DBLoginController: GameInstance set to DBGameInstance_0.
[2015.08.19-14.40.15:485][843]PIE: Info Play in editor start time for /Game/Maps/UEDPIE_0_LoginMap 1
[2015.08.19-14.40.15:485][843]DBNet:Warning: DBGameInstance: Service called. Attepting to call Service from the PhotonClient...
[2015.08.19-14.40.15:486][843]DBNet:Warning: DBNetworkClient. Service called. Calling Service from the PhotonPeer...
But when it comes to the answer from the server it crashes due to IsValidLowLevel() fails:
UE4Editor-CoreUObject.dll!UObjectBase::IsValidLowLevel() Line 213 C++
> UE4Editor-DragonBorn-Win64-DebugGame.dll!DBNetworkListener::onStatusChanged(int statusCode) Line 17 C++
UE4Editor-DragonBorn-Win64-DebugGame.dll!ExitGames::Photon::Internal::PeerBase::deserializeOperation(unsigned char *,int) C++
UE4Editor-DragonBorn-Win64-DebugGame.dll!ExitGames::Photon::Internal::EnetPeer::dispatchIncomingCommands(void) C++
UE4Editor-DragonBorn-Win64-DebugGame.dll!ExitGames::Photon::Internal::PeerBase::service(bool) C++
UE4Editor-DragonBorn-Win64-DebugGame.dll!UDBNetworkClient::PhotonCallService(bool dispatchIncomingCommands) Line 83 C++
UE4Editor-DragonBorn-Win64-DebugGame.dll!UDBGameInstance::PhotonCallService(bool dispatchIncomingCommands) Line 39 C++
UE4Editor-DragonBorn-Win64-DebugGame.dll!ADBLoginController::Tick(float DeltaTime) Line 47 C++
UE4Editor-Engine.dll!AActor::TickActor(float DeltaSeconds, ELevelTick TickType, FActorTickFunction & ThisTickFunction) Line 670 C++
UE4Editor-Engine.dll!FActorTickFunction::ExecuteTick(float DeltaTime, ELevelTick TickType, ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 105 C++
UE4Editor-Engine.dll!FTickTaskSequencer::FTickFunctionTask::DoTask(ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 113 C++
UE4Editor-Engine.dll!TGraphTask<FTickTaskSequencer::FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 753 C++
UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 430 C++
UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 273 C++
UE4Editor-Core.dll!FTaskGraphImplementation::WaitUntilTasksComplete(const TArray<TRefCountPtr<FGraphEvent>,TInlineAllocator<4,FDefaultAllocator> > & Tasks, ENamedThreads::Type CurrentThreadIfKnown) Line 991 C++
UE4Editor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup(ETickingGroup WorldTickGroup, bool bBlockTillComplete) Line 243 C++
UE4Editor-Engine.dll!FTickTaskManager::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 643 C++
UE4Editor-Engine.dll!UWorld::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 697 C++
UE4Editor-Engine.dll!UWorld::Tick(ELevelTick TickType, float DeltaSeconds) Line 1181 C++
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1339 C++
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 366 C++
UE4Editor.exe!FEngineLoop::Tick() Line 2359 C++
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 142 C++
UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 189 C++
UE4Editor.exe!__tmainCRTStartup() Line 618 C
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown
It seems that currentHandler is no longer a valid pointer.
&stc=1But I can not get why.
Edit:
Using IsValidLowLevelFast(true) on the currentHandler gives the result that the pointer is “misaligned”.
[2015.08.19-15.00.05:744][281]DBNet:Warning: DBNetworkClient. Service called. Calling Service from the PhotonPeer...
Function: DBNetworkListener::onStatusChanged(int), Thread: 0x16F8 Main Thread, ExitGames::Photon::Internal::PeerBase::deserializeOperation, 0x000007FED4DFD9AE
[2015.08.19-15.00.05:802][281]LogUObjectBase:Error: 'this' pointer is misaligned.
