dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.39k stars 4.75k forks source link

ExecutionEngineException on using step into while debugging #95417

Open aromaa opened 11 months ago

aromaa commented 11 months ago

Description

When trying to step into a virtual call the runtime unexpectedly throws ExecutionEngineException. Setting the <TieredCompilation>false</TieredCompilation> flag to the project file seems to fix this.

Reproduction Steps

Setting a breakpoint on the following code on L9 and executing step into the 6th time would trigger ExecutionEngineException when attempting to step into the IDbContextDependencies.StateManager on DbContext.

using Microsoft.EntityFrameworkCore;

using TestContext context = new();

TestEntity entity = new();

_ = context.Entities.Entry(entity);

context.Entities.Update(entity); //Start executing step into in this line.

internal sealed record TestEntity(int Id = 0);

internal sealed class TestContext : DbContext
{
    public DbSet<TestEntity> Entities => this.Set<TestEntity>();

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
        optionsBuilder.UseInMemoryDatabase("test");
}

Expected behavior

No exception

Actual behavior

The runtime crashes with ExecutionEngineException

Regression?

No response

Known Workarounds

No response

Configuration

.NET 8 Windows 10 22H2 build 19045.3693 x64 Microsoft Visual Studio Community 2022 Version 17.9.0 Preview 1.0

Other information

No response

ghost commented 11 months ago

Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.

Issue Details
### Description When trying to step into a virtual call the runtime unexpectedly throws ExecutionEngineException. Setting the `false` flag to the project file seems to fix this. ### Reproduction Steps Setting a breakpoint on the following code on L9 and executing step into the 6th time would trigger ExecutionEngineException when attempting to step into the `IDbContextDependencies.StateManager` on `DbContext`. ```csharp using Microsoft.EntityFrameworkCore; using TestContext context = new(); TestEntity entity = new(); _ = context.Entities.Entry(entity); context.Entities.Update(entity); internal sealed record TestEntity(int Id = 0); internal sealed class TestContext : DbContext { public DbSet Entities => this.Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseInMemoryDatabase("test"); } ``` ### Expected behavior No exception ### Actual behavior The runtime crashes with ExecutionEngineException ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration .NET 8 Windows 10 22H2 build 19045.3693 x64 ### Other information _No response_
Author: aromaa
Assignees: -
Labels: `area-Diagnostics-coreclr`, `untriaged`
Milestone: -
MichalPetryka commented 11 months ago

Does <TieredPGO>false</TieredPGO> help too?

aromaa commented 11 months ago

Does <TieredPGO>false</TieredPGO> help too?

It does not.

tommcdon commented 11 months ago

Hi @aromaa! I am not able to reproduce the issue. Would you mind sharing a dump of the target process at the point of the ExecutionEngineException? This can be achieved by getting the app into the reproducible state with the debugger in break state displaying the ExceptionEngineException, and then choosing Debug->Save Dump As.

aromaa commented 11 months ago

Dump

I was unable to take one from VS directly so I used the task manager instead.

tommcdon commented 5 months ago

HI @aromaa I apologize for the delay and have requested access to the dump to investigate.

aromaa commented 5 months ago

You should be able to access it now.

mikelle-rogers commented 3 months ago

@aromaa, just clarifying that by line 9 you mean this line? protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseInMemoryDatabase("test");

aromaa commented 3 months ago

No, I mean literally the L9. The one with the context.Entities.Update(entity);. I have also clarified it in the repro.