Skip to content

develop -> main - #114

Closed
swethasukumarr wants to merge 14 commits into
mainfrom
develop
Closed

develop -> main#114
swethasukumarr wants to merge 14 commits into
mainfrom
develop

Conversation

@swethasukumarr

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 22, 2026 19:55
@dhillomk
dhillomk self-requested a review July 22, 2026 19:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR syncs develop into main, bringing in stability fixes around event-notification delivery (preventing crashes from stale subscription state / callback exceptions), plus CI automation credential updates and a migration of Copilot guidance into a consolidated coding-guidelines document.

Changes:

  • Hardened subscription notification delivery by guarding helper subscription callbacks with a weak_ptr, avoiding use-after-free during unsubscribe races.
  • Made the gateway notification worker resilient to exceptions thrown by callbacks, and added regression tests covering both the weak_ptr guard and exception handling.
  • Updated GitHub Actions workflows to use secrets.AUTOMATION_TOKEN, and replaced the previous Copilot instructions file with a larger coding-guidelines instructions doc.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/helpers_impl.h Stores subscriptions as shared_ptr and wraps gateway callbacks with a weak_ptr guard to drop in-flight notifications safely.
include/firebolt/helpers.h Improves robustness of event property-change callback by catching std::bad_any_cast and refining log text.
src/gateway.cpp Catches exceptions in the notification worker dispatch loop so a single bad callback doesn’t terminate the worker thread.
test/unit/helperTest.cpp Adds regression tests reproducing the unsubscribe/use-after-free race and validating the weak_ptr guard behavior.
test/unit/gatewayTest.cpp Adds a regression test ensuring the notification worker continues after a callback throws.
.github/workflows/sync-develop-to-main.yml Switches automation auth to secrets.AUTOMATION_TOKEN.
.github/workflows/release.yml Switches release auth to secrets.AUTOMATION_TOKEN.
.github/instructions/coding-guidelines.instructions.md Adds consolidated repo coding/testing/build guidelines as an instructions document.
.github/copilot-instructions.md Removed in favor of the new consolidated guidelines document.

Comment thread src/helpers_impl.h
Comment on lines 19 to +23
#include "firebolt/gateway.h"
#include "firebolt/helpers.h"
#include <map>
#include <memory>
#include <mutex>
Comment thread src/helpers_impl.h
Comment on lines +82 to 85
void* notificationPtr = static_cast<void*>(it->second.get());
auto errorStatus{gateway_.unsubscribe(it->second->eventName, notificationPtr)};
subscriptions_.erase(it);
return Result<void>{errorStatus};
Comment thread src/helpers_impl.h
Comment on lines 121 to 125
uint64_t newId = currentId_++;
subscriptions_[newId] = SubscriptionData{owner, eventName, std::move(notification)};
void* notificationPtr = reinterpret_cast<void*>(&subscriptions_[newId]);
auto spData = std::make_shared<SubscriptionData>(SubscriptionData{owner, eventName, std::move(notification)});
subscriptions_[newId] = spData;
void* notificationPtr = static_cast<void*>(spData.get());

Comment thread test/unit/helperTest.cpp
Comment on lines +609 to +618
// ---------------------------------------------------------------------------
// Race condition fix tests (MONUI-908)
//
// These tests validate the weak_ptr guard introduced in HelperImpl::subscribe.
// The guard prevents a use-after-free crash that occurred when:
// 1. The platform sent an event notification (e.g. onSpeechInterrupted).
// 2. Before the worker thread dispatched it, unsubscribeAll() ran and
// destroyed the SubscriptionData object.
// 3. The worker thread then invoked the registered callback with a dangling
// void* pointer → bad_any_cast → std::terminate → device crash.
@dhillomk dhillomk closed this Jul 22, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants