Pass buffer sequences by value in read() and write()#278
Conversation
|
An automated preview of the documentation is available at https://278.capy.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-05-12 19:01:55 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #278 +/- ##
========================================
Coverage 92.37% 92.37%
========================================
Files 168 168
Lines 9414 9414
========================================
Hits 8696 8696
Misses 718 718
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
GCOVR code coverage report https://278.capy.prtest3.cppalliance.org/gcovr/index.html Build time: 2026-05-12 19:17:01 UTC |
The free-function `read` and `write` overloads previously bound the buffer sequence by const reference. With lazy coroutines this dangles: the returned `io_task` can be stored past the full-expression that created the sequence, by which point the const reference points at a destroyed temporary. Switch both to by-value so the sequence lives in the coroutine frame. Update the ReadStream/WriteStream concept docstrings to list only the by-value signature as conforming and document the `std::views::all` caller-side workaround for expensive owning sequences. Append a Resolution section to doc/buffers-passing-rationale.md recording the decision and why both `const&` and `&&` fail under lazy coroutines. Add regression tests that store the returned awaitable past a temporary buffer sequence; verified to trip ASan stack-use-after-scope with the previous signatures and to pass cleanly with by-value. Resolves cppalliance#263.
bffa443 to
d0bfb66
Compare
The free-function
readandwriteoverloads previously bound the buffer sequence by const reference. With lazy coroutines this dangles: the returnedio_taskcan be stored past the full-expression that created the sequence, by which point the const reference points at a destroyed temporary. Switch both to by-value so the sequence lives in the coroutine frame.Update the ReadStream/WriteStream concept docstrings to list only the by-value signature as conforming and document the
std::views::allcaller-side workaround for expensive owning sequences. Append a Resolution section to doc/buffers-passing-rationale.md recording the decision and why bothconst&and&&fail under lazy coroutines.Add regression tests that store the returned awaitable past a temporary buffer sequence; verified to trip ASan stack-use-after-scope with the previous signatures and to pass cleanly with by-value.
Resolves #263.