Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT-LLVM] Compilation failure with async/EH/lock #2641

Closed
yowl opened this issue Aug 1, 2024 · 1 comment
Closed

[NativeAOT-LLVM] Compilation failure with async/EH/lock #2641

yowl opened this issue Aug 1, 2024 · 1 comment
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)

Comments

@yowl
Copy link
Contributor

yowl commented Aug 1, 2024

The following, distilled from

private async Task ConnectAsyncCore(CancellationToken cancellationToken)

public class SafeContext
{
    private static object _lockObject = new object();

    class OperationCanceledException : Exception
    { }

    public static async Task ConnectAsyncCore(CancellationToken cancellationToken)
    {
        Task openTask;

        try
        {
            await Task.CompletedTask;
        }
        catch (OperationCanceledException ex)
        {
            throw;
        }
        catch (Exception)
        {
            lock (_lockObject)
            {
            }
            throw;
        }
    }
}

Causes an assert in the LLVM verification

    Unwind edges out of a funclet pad must have the same unwind dest
      %225 = catchpad within %224 [ptr null], !dbg !5841
      invoke void @llvm.wasm.rethrow() [ "funclet"(token %225) ]
              to label %BT00.4 unwind label %BT02.1, !dbg !5841
      invoke void @RhpRethrow(ptr %142, ptr %141) [ "funclet"(token %225) ]
              to label %BB15.6 unwind label %BT03.1, !dbg !5849
    Assertion failed: !llvm::verifyFunction(*llvmFunc, &llvm::errs()), file C:\github\runtimelab\src\coreclr\jit\llvmcodegen.cpp, l
  ine 830
    abort() has been called

This test is added to the branch, https://github.com/yowl/runtimelab/tree/async-eh, although that is based on the linux CI work, the last commit should be cherry pickable.

cc @SingleAccretion

@jkotas jkotas added the area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly) label Aug 1, 2024
@SingleAccretion
Copy link

The root cause of this bug is the evidently mistaken assumption that mutually-protecting clauses always come adjoint to each other in the Jit's EH table. In other words, same flavor of a bug as what was fixed in dotnet/runtime#104531.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)
Projects
None yet
Development

No branches or pull requests

3 participants