Skip to content

[RuntimeAsync] Two awaits in a Try may not be properly handled. #119611

@VSadov

Description

@VSadov

Observed while enabling rt async in Libraires partition - #119432

The symptom is a number of tests failing with assert like:
Assertion failed 'callInfo.SaveAndRestoreSynchronizationContextField && (callInfo.SynchronizationContextLclNum != BAD_VAR_NUM)' in 'System.IO.Compression.Tests.ZipFile_Extract_Stream:ExtractToDirectoryRoundTrip(bool):this' during 'Transform async' (IL size 90; hash 0x550642b2; Tier0)

The actual reason is the part allInfo.SynchronizationContextLclNum != BAD_VAR_NUM

SynchronizationContextLclNum are introduced when we walk through basic blocks in SaveAsyncContexts. When await is contained in a try, we may split the block to wrap the await in try/finally. That currently may result in not visiting the rest of the block, which may contain another await.

There is an approximate fix in:
4943578

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIruntime-async

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions