Fix Bug #3637: Fix internal crash when WebSocket initialisation fails in monitor mode (#3639)

This PR fixes an internal crash in --monitor mode when WebSocket (Socket.IO) initialisation fails (for example, when Microsoft Graph returns 400 notSupported).

Previously, a failed WebSocket initialisation could leave the internal oneDriveSocketIo object unset (null), while later monitor-loop logic still assumed it was available. This resulted in a null dereference and a SIGSEGV, causing the client to exit after the first monitor loop.
This commit is contained in:
abraunegg 2026-02-12 07:47:18 +11:00 committed by GitHub
commit 2eb89fa062
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 5 deletions

View file

@ -1784,11 +1784,16 @@ class ApplicationConfig {
addLogEntry();
addLogEntry("--------------------DEVELOPER_OPTIONS----------------------------");
addLogEntry("Config option 'force_children_scan' = " ~ to!string(getValueBool("force_children_scan")));
addLogEntry();
addLogEntry("Config option 'monitor_max_loop' = " ~ to!string(getValueLong("monitor_max_loop")));
addLogEntry("Config option 'display_memory' = " ~ to!string(getValueBool("display_memory")));
addLogEntry("Config option 'display_sync_options' = " ~ to!string(getValueBool("display_sync_options")));
addLogEntry("Config option 'display_processing_time' = " ~ to!string(getValueBool("display_processing_time")));
}
// Close out config output
if (getValueBool("display_running_config")) {
addLogEntry("-----------------------------------------------------------------");
addLogEntry();
}
}

View file

@ -1033,6 +1033,8 @@ int main(string[] cliArgs) {
addLogEntry("Enabled WebSocket support to monitor Microsoft Graph API changes in near real-time.");
} else {
addLogEntry("ERROR: Unable to configure WebSocket support to monitor Microsoft Graph API changes in near real-time.");
if (debugLogging) {addLogEntry("Setting 'disable_websocket_support' to 'true' to force WebSockets to be disabled.", ["debug"]);}
appConfig.setValueBool("disable_websocket_support" , true);
}
} else {
// WebSocket Support has been disabled
@ -1403,7 +1405,7 @@ int main(string[] cliArgs) {
Duration nextWebhookCheckDuration = oneDriveWebhook.getNextExpirationCheckDuration();
if (nextWebhookCheckDuration < sleepTime) sleepTime = nextWebhookCheckDuration;
notificationReceived = false;
} else if (!appConfig.getValueBool("disable_websocket_support") && appConfig.curlSupportsWebSockets) {
} else if (oneDriveSocketIo !is null && !appConfig.getValueBool("disable_websocket_support") && appConfig.curlSupportsWebSockets) {
Duration nextWebsocketCheckDuration = oneDriveSocketIo.getNextExpirationCheckDuration();
if (nextWebsocketCheckDuration < sleepTime) sleepTime = nextWebsocketCheckDuration;
}
@ -1856,9 +1858,16 @@ extern(C) nothrow @nogc @system void exitViaSignalHandler(int signo) {
if (signo == SIGSEGV) {
// Was SIGTERM used?
if (!sigtermHandlerTriggered) {
// No .. so most likely SIGINT (CTRL-C)
printf("Due to a termination signal, internal processing stopped abruptly. The application will now exit in a unclean manner.\n");
exit(130);
// No .. so most likely SIGINT (CTRL-C) - lets check
if (signo == SIGINT) {
// Yes - SIGINT was used
printf("Due to a termination signal, internal processing stopped abruptly. The application will now exit in a unclean manner.\n");
exit(130);
} else {
// Confirmed as SIGSEGV, but not SIGINT and SIGTERM not used
printf("FATAL: Segmentation fault (SIGSEGV). The application encountered an internal error and will now exit in a unclean manner.\n");
exit(139);
}
} else {
// High probability of being shutdown by systemd, for example: systemctl --user stop onedrive
// Exit in a manner that does not trigger an exit failure in systemd