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
Intermittent System.ExecutionEngineException with EF Core DBContext #11873
Comments
This issue was moved to dotnet/efcore#14495 |
@RussKeldorph See dotnet/efcore#14487 If there is something more that we can do here on the EF side, then please let us know. |
@camainc Sorry, there was no reference to the EF issue so I assumed you had come straight here. We may not be able to help without the ability to reproduce it. @dotnet/dotnet-diag may have more specific advice. |
I understand. If there were more information available, it would at least give me a pointer in the right direction, but there is no stack trace, no inner exception, or anything else to go on. And I'm not smart enough to delve into the underlying CLR source. |
I just wonder if it has anything to do with dependency injection. |
What would be most helpful to debug this is to capture a dump of the debuggee prior to continuing from that exception/killing the debuggee. If you are using Visual Studio you should be able to capture the dump via the Debug menu > Save Dump As. Once you have that dump just share it with us and we can investigate what may be going wrong. |
Here is a link to the file on my OneDrive. |
Thanks @camainc ! I've started investigating and I see likely chain of things going wrong, I don't have a root cause yet but making progress. So far I can't find any obvious connection between using the debugger and this failure. It could be that connection is subtle and we haven't dug deep enough yet, but if you are able to reproduce this failure without the debugger please let me know. Also if the failure happens again it would be great to get a second dump for comparison in order to learn if the issue is consistent. In terms of investigating, here is what I am seeing so far.
Progress continues, I'll let you know once we've got more... |
Wow, thanks! I'll upload another dump tomorrow. The error happens literally every other time I start debugging, so it won't be hard to get a new dump file. |
Here is the second dump file. Thanks again for your help. |
@camainc thanks for providing these dumps. With some further investigating by my teammate we've likely connected your issue to a bug in the runtime that was discovered last year. We have implemented a fix that is included in the forthcoming .Net 4.8 release and we've got some options for you to try that will hopefully workaround the issue using the build of .NET you already have. The primary goal of all these workarounds is to avoid using an NGEN image for netstandard.dll and instead to use the IL image. The options are different ways of achieving that and you can pick whichever one is easiest to use/affects the right scope of processes:
If there is an existing file with a <configuration>, <runtime> or <disableNativeImageLoad> block, then the elements described above need to be "spliced in" to the existing blocks (i.e., I believe the CLR config file parser might have trouble if multiple blocks of the same name are listed).
Before editing it is a good precaution to save a copy of the existing file in case you need to roll back the change for any reason, then make the same edit as used for the app.exe.config case above. I hope one of these options can you get debugging successfully and sorry for the trouble this has caused. -Noah |
Thank you so much for your excellent work and the detailed workarounds. Am I safe to assume that this bug only affects debugging, and won't be a problem in a release version? We haven't deployed this yet, but I don't know when the IT folks will get around to upgrading to version 4.8. We had to push a bit to get them to allow us to use 4.6.2. Thank you again! I will try your suggested workarounds and see what happens. |
I think dotnet/coreclr#5 has fixed this for me. Thank you! |
As best I can tell there actually wasn't anything debugger specific about the bug, but its always possible there was a connection there I missed. I would suggest that if you are already running this in production and see no issue, don't fix what isn't broken. However if you haven't deployed this to production yet it might be worth doing one of these workarounds to head off potential trouble. All of these workarounds should be safe for production usage because NGEN images have always been optional. Depending on your application you might see slight differences in performance numbers such as startup time or working set. If those stats have high importance for you can always measure to determine the exact impact. Sorry on the slow response, I broke my github notifications for a bit there. Glad to hear you were able to get things working though! |
Closing this issue as it seems resolved. |
Thanks for the awesome help. I would never have figured this out on my own, and neither StackOverflow or Google was any help with this. Being able to get a response directly from the developers is GOLDEN. You guys rock. |
How can I accomplish this if my application is deployed to the client environment? I was moving my code from EF6 to EF Core but this error started to occur (I'm also using Autofac). Should I keep using EF6 until .net 4.8 is released? Btw, this seems to have fixed the problem:
|
It really depends what control you have over that client environment. For example in the likely case that you make an installer that contains your app and it copies files to the client then you could probably do option 4 and include the config file as part of your app. Does that answer what you were looking for or was there some other issue you forsee? |
Option 4 will work on both x86 and x64?
A sexta, 24/05/2019, 22:59, Noah Falk <notifications@github.com> escreveu:
… How can I accomplish this if my application is deployed to the client
environment?
It really depends what control you have over that client environment. For
example in the likely case that you make an installer that contains your
app and it copies files to the client then you could probably do option 4
and include the config file as part of your app. Does that answer what you
were looking for or was there some other issue you forsee?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/dotnet/coreclr/issues/22137?email_source=notifications&email_token=ABJXYAEQ6NCMZGPNSNXN4IDPXBQNNA5CNFSM4GRXBBU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGUWCA#issuecomment-495799048>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJXYABVIPU6OA476XAIYYLPXBQNNANCNFSM4GRXBBUQ>
.
|
Yep : ) |
Then that option is valid. I'll give it a try and give you feedback.
Thanks for the help!
A sexta, 24/05/2019, 23:06, Noah Falk <notifications@github.com> escreveu:
… Option 4 will work on both x86 and x64?
Yep : )
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/dotnet/coreclr/issues/22137?email_source=notifications&email_token=ABJXYAELP4RCYKFG54X2Q43PXBRE3A5CNFSM4GRXBBU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGVAFY#issuecomment-495800343>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJXYAARYMZZA5G46RE3SZ3PXBRE3ANCNFSM4GRXBBUQ>
.
|
Where do I add Any ideas to solve this issue? Btw, is this related directly to EF Core? If I change back to EF6 this problem will go away? |
After updating the nuget packages in my solution, I started experiencing this error when starting a debug session. It happens almost every other time I start debugging. The stack trace is empty, there is no inner exception, and the only thing I can do is stop execution and then restart the debugging session.
Exception message:
System.ExecutionEngineException
HResult=0x80131506
Message=Exception of type 'System.ExecutionEngineException' was thrown.
Stack trace: Empty
Steps to reproduce
protected WinsDbContextBase(DbContextOptions options, ICurrentUserContext userContext)
: base(options) <== The error occurs here
{
...
}```
Further technical details
EF Core version: (found in project.csproj or packages.config) 2.2.1
Database Provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) SqlServer
Operating system: Windows 10
IDE: (e.g. Visual Studio 2017 15.4) VS 2017 15.9.5
The text was updated successfully, but these errors were encountered: