Skip to content

Fix encoding of weak actor handles - #2398

Draft
Neverlord wants to merge 1 commit into
mainfrom
gh-2397-weak-pointer-serialization
Draft

Fix encoding of weak actor handles#2398
Neverlord wants to merge 1 commit into
mainfrom
gh-2397-weak-pointer-serialization

Conversation

@Neverlord

Copy link
Copy Markdown
Member

Closes #2397.

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

Fixes serialization of weak_actor_ptr (including expired handles) by delegating weak-handle encoding/decoding to the actor_handle_codec, ensuring down/exit messages remain serializable even when no strong reference exists locally (per #2397).

Changes:

  • Route serializer::value(weak_actor_ptr) / deserializer::value(weak_actor_ptr) through actor_handle_codec instead of upgrading to a strong handle.
  • Extend actor_handle_codec and detail::default_actor_handle_codec with explicit save/load for weak_actor_ptr, including proper handling for expired weak handles (serialize ID+node without registering).
  • Add a new regression test covering strong handles, valid weak handles, and expired weak handles across binary and JSON formats; remove now-unneeded save_actor/load_actor free functions from the public API.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
libcaf_core/caf/serializer.cpp Uses actor_handle_codec to serialize weak_actor_ptr directly.
libcaf_core/caf/deserializer.cpp Uses actor_handle_codec to deserialize weak_actor_ptr directly.
libcaf_core/caf/actor_handle_codec.hpp Makes weak-handle save/load part of the codec vtable (pure virtual).
libcaf_core/caf/detail/default_actor_handle_codec.hpp Declares weak-handle save/load overrides.
libcaf_core/caf/detail/default_actor_handle_codec.cpp Implements weak-handle save/load, including expired weak-handle behavior.
libcaf_core/caf/detail/stringification_inspector.cpp Implements weak-handle save/load for stringification codec.
libcaf_core/caf/actor_control_block.hpp Removes public declarations of save_actor/load_actor.
libcaf_core/caf/actor_control_block.cpp Removes definitions of save_actor/load_actor.
libcaf_core/caf/detail/default_actor_handle_codec.test.cpp Adds tests for strong/weak/expired-weak roundtrips and encoding expectations.
libcaf_core/CMakeLists.txt Adds the new test file to the build.
CHANGELOG.md Documents removal of save_actor/load_actor from the public API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libcaf_core/caf/detail/default_actor_handle_codec.test.cpp Outdated
Comment thread CHANGELOG.md
Comment thread libcaf_core/caf/actor_handle_codec.hpp
@Neverlord
Neverlord force-pushed the gh-2397-weak-pointer-serialization branch from 8030967 to f921357 Compare April 30, 2026 11:42
@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.57377% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.23%. Comparing base (556c0ea) to head (f921357).

Files with missing lines Patch % Lines
...caf_core/caf/detail/default_actor_handle_codec.cpp 80.85% 3 Missing and 6 partials ⚠️
...bcaf_core/caf/detail/stringification_inspector.cpp 0.00% 6 Missing ⚠️
libcaf_core/caf/deserializer.cpp 25.00% 2 Missing and 1 partial ⚠️
libcaf_core/caf/serializer.cpp 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2398      +/-   ##
==========================================
+ Coverage   73.08%   73.23%   +0.15%     
==========================================
  Files         636      636              
  Lines       30525    30551      +26     
  Branches     3342     3344       +2     
==========================================
+ Hits        22310    22375      +65     
+ Misses       6304     6260      -44     
- Partials     1911     1916       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Issue with serializing weak pointers

2 participants