Fix SendHeartbeat crash when HTTP module is unloaded during engine shutdown - #197
Draft
Dimitris Gkanatsios (dgkanatsios) with Copilot wants to merge 4 commits into
Draft
Fix SendHeartbeat crash when HTTP module is unloaded during engine shutdown#197Dimitris Gkanatsios (dgkanatsios) with Copilot wants to merge 4 commits into
Dimitris Gkanatsios (dgkanatsios) with Copilot wants to merge 4 commits into
Conversation
Copilot started work on behalf of
Dimitris Gkanatsios (dgkanatsios)
March 3, 2026 19:43
View session
…utdown Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crash in FGSDKInternal::SendHeartbeat during engine shutdown
Fix SendHeartbeat crash when HTTP module is unloaded during engine shutdown
Mar 3, 2026
Copilot started reviewing on behalf of
Dimitris Gkanatsios (dgkanatsios)
August 7, 2026 01:51
View session
There was a problem hiding this comment.
Pull request overview
This PR updates the Unreal PlayFab GSDK plugin’s async heartbeat sender to avoid crashing during engine shutdown when Unreal’s HTTP module has already been unloaded.
Changes:
- Added an
IsModuleLoaded("HTTP")guard inFGSDKInternal::SendHeartbeat()to skip sending heartbeats if the HTTP module is unavailable. - Applied the same change to both the main plugin source and the TestingProject plugin copy.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| UnrealPlugin/Source/PlayFabGSDK/Private/GSDKInternal.cpp | Adds an HTTP-module-loaded check before creating heartbeat HTTP requests to avoid shutdown-time null deref. |
| UnrealPlugin/TestingProject/Plugins/PlayFabGSDK/Source/PlayFabGSDK/Private/GSDKInternal.cpp | Mirrors the same shutdown guard change in the TestingProject plugin copy. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Dimitris Gkanatsios (dgkanatsios)
August 7, 2026 17:14
View session
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
UnrealPlugin/TestingProject/Plugins/PlayFabGSDK/Source/PlayFabGSDK/Private/GSDKInternal.cpp:211
- If the HTTP module unloads before this async heartbeat thread exits, this path can execute every heartbeat interval until FGSDKInternal is destroyed, producing repeated Warning logs during engine shutdown. Consider downgrading to Verbose (or logging once) and stopping the heartbeat loop when the module is missing to avoid log spam and needless work.
FHttpModule* HttpModule = FModuleManager::Get().GetModulePtr<FHttpModule>(TEXT("HTTP"));
if (!HttpModule)
{
UE_LOG(LogPlayFabGSDK, Warning, TEXT("HTTP module is not loaded, skipping heartbeat."));
return;
UnrealPlugin/Source/PlayFabGSDK/Private/GSDKInternal.cpp:211
- If the HTTP module unloads before this async heartbeat thread exits, this path can execute every heartbeat interval until FGSDKInternal is destroyed, producing repeated Warning logs during engine shutdown. Consider downgrading to Verbose (or logging once) and stopping the heartbeat loop when the module is missing to avoid log spam and needless work.
FHttpModule* HttpModule = FModuleManager::Get().GetModulePtr<FHttpModule>(TEXT("HTTP"));
if (!HttpModule)
{
UE_LOG(LogPlayFabGSDK, Warning, TEXT("HTTP module is not loaded, skipping heartbeat."));
return;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
FGSDKInternal::SendHeartbeat()can crash via nullptr dereference onFHttpModule::Get().CreateRequest()when the HTTP module has already been unloaded during engine shutdown. The heartbeat runs on an async thread, so depending on timing, it may attempt to access the HTTP module after the GameThread has unloaded it.Adds an
IsModuleLoadedguard at the top ofSendHeartbeat():Applied to both
UnrealPlugin/Source/andUnrealPlugin/TestingProject/Plugins/copies.Special notes for your reviewer:
As noted in the issue, there is a theoretical TOCTOU race between the
IsModuleLoadedcheck and the subsequentFHttpModule::Get()call. In practice, the window is negligibly small and this is the standard UE pattern for this class of problem. A fully thread-safe solution would require architectural changes to the heartbeat lifecycle (e.g., preventing module unload until the heartbeat thread exits), which is out of scope here.If applicable:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.