Dedicated server crash "GameModeBase.HandleStartingNewPlayer"

Hello everybody,

my dedicated server crash when the first player is joining. The only output in log is the following:

“LogOutputDevice: Warning: Script Stack (1 frames): GameModeBase.HandleStartingNewPlayer”
“LogWindows: Windows GetLastError: The operation completed successfully. (0)”
“Log file closed, 11/02/21 15:56:41”

No callstack is present !

A report is present in the Crashes folder but “UE4Minidump.dmp” is empty (0 KB) and in “CrashContext.runtime-xml” the only “readable” information is: “Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:C:\UE4.27\Engine\Source\Runtime\Core\Public\Containers/Array.h] [Line: 703]
Array index out of bounds: 24 from an array of size 24”

The rest is callstacks with adresses (not path and line): "rigidityServer-Win64-DebugGame 0x00007ff6a7240000 + 1c27a7b "

Context: The server has been compiled in DebugGame mode and contains the .pdb file.

How can I have more information to debug it ? Compiling the server in Development mode would add callstack in log ?

I’m using AWS Gamelift, so I can’t reproduce it locally. I have distance access to the instance but it does not have VS installed to do live debugging.

I’m pretty stuck here with so few information about what’s going wrong.

Any help is appreciated !

PS: Of course everything works perfectly in the editor with “PIE” and “Standalone Game” play mode.

Hey folks, some update.

After some digging, override game mode HandleStartingNewPlayer and copy/pasting engine code until I could not override the called function, I have a part of callstack:

  • AGameModeBase::FinishRestartPlayer line 1306
  • AGameModeBase::RestartPlayerAtPlayerStart line 1262
  • AGameModeBase::RestartPlayer line 1196
  • AGameModeBase::HandleStartingNewPlayer_Implementation line 1029

I can’t go any further because AGameModeBase::FinishRestartPlayer line 1306 is the following line: “NewPlayer->Possess(NewPlayer->GetPawn());” it’s when the controller possess the spawned Pawn (Possess is a final function I cannot override it to see further).

I then replaced my custom controller by the default APlayerController class. It crashes exactly the same.

I’m starting to be out of ideas…

Any help appreciated !

Hi,

I compiled the dedicated server in Debug mode to see if it would generate more information about the crash.

No crash dump now but the log is more explicit now:

LogUObjectBase: Error: ‘this’ pointer is misaligned.
LogOutputDevice: Warning: Script Stack (0 frames):
LogWindows: Windows GetLastError: The operation completed successfully. (0)
LogWindows: Error: Fatal error: [File:C:/Users/Tristan/Documents/UE4.27/Engine/Source/Runtime/CoreUObject/Private/UObject/GarbageCollection.cpp] [Line: 961]
LogWindows: Error: Invalid object in GC: 0xcccccccccccccccc, ReferencingObject: BP_Gmode_DM_C /Game/Arenas/Maps/DM_Heaven/DM_Heaven.DM_Heaven:PersistentLevel.BP_Gmode_DM_C_2147482568, ReferencingObjectClass: BlueprintGeneratedClass /Game/Arenas/GameMode/DM/BP_Gmode_DM.BP_Gmode_DM_C, Property Name: AController, Offset: 48, TokenIndex: 54
LogExit: Executing StaticShutdownAfterError

I’ll try to understand why the Gmode is being garbage collected.

If any one has an idea don’t hesitate, thanks.

Hello,

I finally found “the problem” by removing codes function with dichotomy
methodology.

Below the code, I hope it’ll help:

    FString Json = gameSession.GetMatchmakerData();
	TSharedPtr<FJsonObject> JsonObject;
	TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Json);
	FPlayerData PlayerData;

	if (FJsonSerializer::Deserialize(Reader, JsonObject) && JsonObject->HasField("teams")) {
		const TArray<TSharedPtr<FJsonValue>> Arr_Teams = JsonObject->GetArrayField("teams");

		for (int i = 0; i < Arr_Teams.Num(); i++) {
			const TSharedPtr<FJsonObject> TeamJsonObject = Arr_Teams[i]->AsObject();
			const TArray<TSharedPtr<FJsonValue>> Arr_Players = TeamJsonObject->GetArrayField("players");
			for (int j = 0; j < Arr_Players.Num(); j++) {
				this->Arr_PlayerDatas.Add(FPlayerData(*Arr_Players[j]->AsObject().Get())); //this line was the problem
			}
		}
	}

I replaced the problematic line by:

PlayerData = FPlayerData();
PlayerData.InitJson(*Arr_Players[j]->AsObject().Get());
this->Arr_PlayerDatas.Add(PlayerData);

For info FPlayerData is USTRUCT. Refactoring the custom construct to a function (InitJson) did the trick.

Have a good week-end.

Had a question about this, did this randomly started happening to you or was this the first time you tried?

Actually I figured out that I recently deleted the event handle started new player. Adding it back to the blueprint fixed the problem.