Skip to content

fix(io): guard null target in any_* rollback; raise test coverage to …#302

Merged
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/coverage
Jun 5, 2026
Merged

fix(io): guard null target in any_* rollback; raise test coverage to …#302
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/coverage

Conversation

@sgerbino
Copy link
Copy Markdown
Collaborator

@sgerbino sgerbino commented Jun 5, 2026

…~98%

Fix a memory-safety bug in the any_* type-erased wrappers: the owning- construction rollback guard called vt_->destroy(target_) unconditionally, but if the wrapped stream/source/sink move-constructor throws, the placement-new never assigns the target pointer, so destroy ran ~T() on a null pointer (SIGSEGV for any type whose destructor touches a member). Guard the destroy on a non-null target across all six wrappers. Confirmed to crash before the fix and pass under ASan after.

Raise library line coverage from ~94% to ~98% by closing real gaps:

  • throw_* helpers and error/cond category messages incl. default branches
  • run_callbacks handler_pair specializations and frame_memory_resource
  • call_await_suspend void/bool/handle branches and get_awaiter paths
  • executor_ref/any_executor work-tracking, cross-type equality, target<>
  • every any_* wrapper: type-erased await_suspend forwarding (via resuming mocks the always-ready test mocks never reached), owning move-assign teardown, and throwing-move construction regression tests
  • run_async value-type allocator trampoline
  • read_until multi-buffer linearize, lvalue buffer, and match_delim hint
  • buffer operator+= clamping

Remaining uncovered lines are defensive/unreachable: local awaiter methods that never suspend, terminate() paths, allocation-failure rollback, and reentrancy guards.

…~98%

Fix a memory-safety bug in the any_* type-erased wrappers: the owning-
construction rollback guard called vt_->destroy(target_) unconditionally,
but if the wrapped stream/source/sink move-constructor throws, the
placement-new never assigns the target pointer, so destroy ran ~T() on a
null pointer (SIGSEGV for any type whose destructor touches a member).
Guard the destroy on a non-null target across all six wrappers. Confirmed
to crash before the fix and pass under ASan after.

Raise library line coverage from ~94% to ~98% by closing real gaps:

  - throw_* helpers and error/cond category messages incl. default branches
  - run_callbacks handler_pair specializations and frame_memory_resource
  - call_await_suspend void/bool/handle branches and get_awaiter paths
  - executor_ref/any_executor work-tracking, cross-type equality, target<>
  - every any_* wrapper: type-erased await_suspend forwarding (via resuming
    mocks the always-ready test mocks never reached), owning move-assign
    teardown, and throwing-move construction regression tests
  - run_async value-type allocator trampoline
  - read_until multi-buffer linearize, lvalue buffer, and match_delim hint
  - buffer operator+= clamping

Remaining uncovered lines are defensive/unreachable: local awaiter
methods that never suspend, terminate() paths, allocation-failure
rollback, and reentrancy guards.
@cppalliance-bot
Copy link
Copy Markdown

An automated preview of the documentation is available at https://302.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-06-05 15:01:51 UTC

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.46%. Comparing base (98be9fd) to head (c306e46).

Files with missing lines Patch % Lines
include/boost/capy/io/any_buffer_sink.hpp 50.00% 1 Missing ⚠️
include/boost/capy/io/any_buffer_source.hpp 50.00% 1 Missing ⚠️
include/boost/capy/io/any_read_source.hpp 50.00% 1 Missing ⚠️
include/boost/capy/io/any_read_stream.hpp 50.00% 1 Missing ⚠️
include/boost/capy/io/any_write_sink.hpp 50.00% 1 Missing ⚠️
include/boost/capy/io/any_write_stream.hpp 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #302      +/-   ##
===========================================
+ Coverage    92.27%   96.46%   +4.19%     
===========================================
  Files          164      164              
  Lines         8862     8951      +89     
===========================================
+ Hits          8177     8635     +458     
+ Misses         685      316     -369     
Flag Coverage Δ
linux 96.58% <ø> (+4.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/boost/capy/io/any_buffer_sink.hpp 99.64% <50.00%> (+12.81%) ⬆️
include/boost/capy/io/any_buffer_source.hpp 99.42% <50.00%> (+12.79%) ⬆️
include/boost/capy/io/any_read_source.hpp 98.52% <50.00%> (+7.41%) ⬆️
include/boost/capy/io/any_read_stream.hpp 98.95% <50.00%> (+11.58%) ⬆️
include/boost/capy/io/any_write_sink.hpp 98.59% <50.00%> (+8.02%) ⬆️
include/boost/capy/io/any_write_stream.hpp 99.01% <50.00%> (+4.96%) ⬆️

... and 32 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98be9fd...c306e46. Read the comment docs.

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

@cppalliance-bot
Copy link
Copy Markdown

GCOVR code coverage report https://302.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://302.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://302.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-06-05 15:23:36 UTC

@sgerbino sgerbino merged commit ce1c7d7 into cppalliance:develop Jun 5, 2026
38 checks passed
@sgerbino sgerbino deleted the pr/coverage branch June 5, 2026 15:38
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.

2 participants