Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreal: FGSDKInternal::SendHeartbeat() may crash after the engine's shutdown phase because the HTTP module is unloaded #153

Open
yoanlcq opened this issue Jul 26, 2023 · 1 comment

Comments

@yoanlcq
Copy link

yoanlcq commented Jul 26, 2023

Hi,

Describe the bug

FGSDKInternal::SendHeartbeat() may crash after the engine's shutdown phase.
Because this happens in async code, this does not always occur, depending on timings.

The crash occurs due to a nullptr dereference at the line FHttpModule::Get().CreateRequest() in FGSDKInternal::SendHeartbeat(), after the engine's shutdown phase (when the game server requests exits and all modules are unloaded).
The only way this could happen would be because the HTTP module is unloaded, and because we're in the shutdown phase, the module is not allowed to be loaded again.

To prevent this, the following snippet could be inserted at the beginning of FGSDKInternal::SendHeartbeat():

	if (!FModuleManager::Get().IsModuleLoaded(TEXT("HTTP")))
		return;

However, it would still not be thread-safe: it's technically possible for the HTTP module to be unloaded on the GameThread at the exact same time it is accessed from the async thread.

To Reproduce

  1. Run any dedicated server built with Unreal Engine and the PlayFab GSDK; For this, use PlayFab's LocalMultiplayerAgent tool.
  2. Make the server exit normally (one way to do this is FGenericPlatformMisc::RequestExit(false))
  3. The aforementioned crash may occur because FHttpModule::Get() returns nullptr.
@nassosterz-ms
Copy link
Contributor

Thank you for reporting this and truly appreciate providing potential solutions. We will investigate and update the repo with a fix for this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants