Skip to content

Add coroutine-hostile-raii lint for UnwindDetector, and add fixes - #7153

Open
jtolio wants to merge 1 commit into
mainfrom
jolio/add-coroutin-iivvz5
Open

Add coroutine-hostile-raii lint for UnwindDetector, and add fixes#7153
jtolio wants to merge 1 commit into
mainfrom
jolio/add-coroutin-iivvz5

Conversation

@jtolio

@jtolio jtolio commented Aug 27, 2026

Copy link
Copy Markdown
Member

This change adds a lint to prevent usage of UnwindDetector across coroutine pauses. See discussion on capnproto/capnproto#2789 why UnwindDetector is not safe on coroutines.

The fixes in container-client fix not only the lint but also what appears to be the code's intent.

The lints are fixed in standard.c++ but the behavior is unchanged and may be buggy. I'm not sure it is intended that the KJ_CATCH branch does not run when writeFailed == true.

Added TODOs for a later followup.

@jtolio
jtolio requested review from a team as code owners August 27, 2026 20:57
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@jtolio
jtolio force-pushed the jolio/add-coroutin-iivvz5 branch from a0fc3a8 to ce193e4 Compare August 27, 2026 21:08
@ask-bonk

ask-bonk Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@jtolio Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

The fixes in container-client fix not only the lint but also
what appears to be the code's intent.

The lints are fixed in standard.c++ but the behavior is unchanged
and may be buggy. I'm not sure it is intended that the KJ_CATCH
branch does not run when writeFailed == true.

Added TODOs for a later followup.
@jtolio
jtolio force-pushed the jolio/add-coroutin-iivvz5 branch from ce193e4 to c03731f Compare August 27, 2026 21:30
if (result.chunks.size() > 0) {
KJ_ON_SCOPE_FAILURE(writeFailed = true);
auto invocation = KJ_CO_MAGIC kj::CURRENT_INVOCATION;
// TODO(soon) - should this also handle invocation.isCanceling()?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, but @jasnell could perhaps confirm: If someone drops this pumpToImpl() coroutine's promise, should we set writeFailed = true?

I think the KJ_ON_SCOPE_FAILURE was probably just meant to be equivalent to a .catch_(), and not consider cancellation.

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