Repository navigation
Clarify that runtime-async suspension points are forbidden in handlers, not try blocks - #132426
Merged
jakobbotsch merged 1 commit intoAug 17, 2026
Conversation
"Exception handling blocks" reads naturally as the whole try/catch construct. The implementation means the handler: the runtime's own tests await inside try blocks under runtime-async. Name the four handler kinds ECMA-335 defines, and state that the protected block is permitted.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 15 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke |
jakobbotsch
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docs/design/specs/runtime-async.mdlists, under restrictions likely to be permanent:The intended meaning is clear enough on a careful reading — "exception handling block" is the handler block — but it is easy to read as the whole
try/catchconstruct, including the protectedtryblock. Under that readingawaitinside atrywould be forbidden, which would rule out a shape the runtime's own tests exercise. Naming the handler explicitly removes the ambiguity.ECMA-335 defines four handler kinds, so the enumeration names all four:
catch,filter,finallyandfault. C# never emitsfault, but IL from other producers does, and this document is an ECMA-335 augment rather than a C# specification.Evidence from this repository
src/tests/async/simple-eh/simple-eh.csawaits inside atrywith acatch, in a method that is not opted out of runtime-async generation:The methods in that file which must not be runtime-async are explicitly marked
[RuntimeAsyncMethodGeneration(false)];Handleris not among them.src/tests/async/eh-microbench/eh-microbench.csgoes further, deliberately injecting atry/finallyaround awaits at a configurable rate — "Inject a finally every N frames" — as a runtime-async benchmark arm.Evidence from a shipping SDK
Built against
11.0.100-preview.5.26302.115with<Features>runtime-async=on</Features>, reading the emitted metadata and IL back:ImplAttributesAsyncHelperssuspension point sitsawaitin atrywith acatch0x2000(Async)call @0x0018, try[0x0000,0x0028)awaitin atrywith afinally0x2000(Async)call @0x001A, try[0x0002,0x002A)awaitwritten inside acatchhandler0x2000(Async)[0x0002,0x000B)/ handler[0x000B,0x0010)awaitwritten inside afinallyhandler0x2000(Async)All four compile and run correctly.
The third and fourth rows may be worth a sentence in the spec as well, since they are the natural follow-up question and are not stated anywhere: when a source-level
awaitappears in a handler, the compiler lowers it out of the handler rather than abandoning runtime-async codegen for the method — the method remainsMethodImplOptions.Async. I have left that out of this change to keep it to the one ambiguity, but I am happy to add it if you would like.Why it is worth changing
The sentence is load-bearing for anyone writing an IL rewriter, profiler, or analyzer against this spec, and the two readings differ on whether a whole class of instrumentation is viable at all. A more careful reading resolves it; this wording means no one has to arrive at that reading on their own.