Skip to content

Fix CFI icall violation in Future callbacks - #1914

Merged
a-maurice merged 4 commits into
mainfrom
am-future_fix
Aug 31, 2026
Merged

Fix CFI icall violation in Future callbacks#1914
a-maurice merged 4 commits into
mainfrom
am-future_fix

Conversation

@a-maurice

@a-maurice a-maurice commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

Provide details of the change, and generalize the change in the PR title above.

Eliminate unsafe reinterpret_cast of TypedCompletionCallback and std::function completion callbacks to FutureBase::CompletionCallback in Future::OnCompletion and Future::AddOnCompletion.

Introduce type-safe trampoline functions and wrapper data structures (TypedCompletionCallbackTrampoline and TypedCompletionCallbackData) in firebase::detail to bridge the typed callback to the base callback signature expected by ReferenceCountedFutureImpl::RunCallback, avoiding undefined behavior and runtime CFI type check aborts.


Testing

Describe how you've tested these changes. Link any manually triggered Integration tests or CPP binary SDK Packaging Github Action workflows, if applicable.


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

@a-maurice a-maurice added the tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). label Aug 27, 2026
@github-actions github-actions Bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). labels Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

❌  Integration test FAILED

Requested by @a-maurice on commit 79c2210
Last updated: Mon Aug 31 20:10 PDT 2026
View integration test log & download artifacts

Failures Configs
missing_log [TEST] [ERROR] [Android] [All 3 os] [1/2 android_device: android_target]
functions [TEST] [FLAKINESS] [iOS] [macos] [1/2 ios_device: ios_target]
(1 failed tests)  CRASH/TIMEOUT
installations [TEST] [FAILURE] [iOS] [macos] [1/2 ios_device: simulator_target]
(1 failed tests)  FirebaseInstallationsTest.TestCanGetToken

Add flaky tests to go/fpl-cpp-flake-tracker

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the Future<T>::OnCompletion and Future<T>::AddOnCompletion implementations to avoid unsafe reinterpret_cast on callbacks, introducing a typed callback data structure and trampoline functions instead. The review feedback highlights critical safety issues regarding null or empty callbacks: passing a null callback can cause a crash if the future is already completed, and wrapping an empty std::function without validation can trigger a std::bad_function_call exception or crash. Suggestions are provided to handle these cases safely by using dummy callbacks or adding validity checks.

Comment thread app/src/include/firebase/internal/future_impl.h Outdated
Comment thread app/src/include/firebase/internal/future_impl.h Outdated
Comment thread app/src/include/firebase/internal/future_impl.h
@github-actions github-actions Bot added the tests: succeeded This PR's integration tests succeeded. label Aug 27, 2026
@firebase-workflow-trigger firebase-workflow-trigger Bot removed the tests: in-progress This PR's integration tests are in progress. label Aug 27, 2026
@a-maurice a-maurice added the skip-release-notes Skip release notes check label Aug 31, 2026
@a-maurice
a-maurice requested a review from AustinBenoit August 31, 2026 19:45
@a-maurice
a-maurice merged commit 79c2210 into main Aug 31, 2026
39 checks passed
@a-maurice
a-maurice deleted the am-future_fix branch August 31, 2026 21:52
@github-actions github-actions Bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests: succeeded This PR's integration tests succeeded. labels Aug 31, 2026
@firebase-workflow-trigger firebase-workflow-trigger Bot removed the tests: in-progress This PR's integration tests are in progress. label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-release-notes Skip release notes check tests: failed This PR's integration tests failed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants