Skip to content

fix: Harden FDv1 data source destination and status-manager lifetimes - #603

Draft
beekld wants to merge 3 commits into
mainfrom
bklimt/SDK-3019/fdv1-adapter-close-uaf
Draft

fix: Harden FDv1 data source destination and status-manager lifetimes#603
beekld wants to merge 3 commits into
mainfrom
bklimt/SDK-3019/fdv1-adapter-close-uaf

Conversation

@beekld

@beekld beekld commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

The FDv1 streaming and polling sources received their destination and status manager as a raw pointer and reference. A source callback still in flight during teardown could reach those objects after the owner freed them. This is the use-after-free reported in #602.

The handoff now uses smart-pointer handles.

  • IDataSynchronizer::StartAsync takes a shared_ptr<IDestination>.
  • The sources observe the destination through a weak_ptr and hold the status manager as a shared_ptr. Neither can dangle.
  • The FDv2 fallback adapter, BackgroundSync, and ClientImpl own these objects via shared_ptr.

The concrete sources already guarded their own callbacks, so the reported crash was latent rather than reachable through the public API. This change makes the lifetime safe by construction regardless of source behavior.

No public API change. ClientImpl::DataSourceStatus() returns the same reference as before.

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

Successfully merging this pull request may close these issues.

1 participant