runtime: ExecutionEngineException in WinForms app (Paint.NET) on .NET 8 RC2, which does not occur in .NET 7 (GCStress)
Description
I’ve had two spurious EEE’s pop out at me while I was in the debugger over the last week, working on the new version of my app (Paint.NET v5.1) that is targeting .NET 8. I was worried it was due to my new code, some of which is clipboard related (always a bug farm) …
… But I’m now able to reproduce this 100% with my latest public release (Paint.NET v5.0.11, .NET 7.0.12), when it’s retargeted for .NET 8. It has no trouble with .NET 7.
I believe this is a new bug in .NET 8, it’s not due to any changes I’ve made in my code.
Reproduction Steps
You will need access to https://github.com/dotnet/paint.net/ – just ask and I will add you (for MSFT employees that is)
You will want this branch: https://github.com/dotnet/paint.net/tree/net8_EEE_repro . This is branched from v5.0.11, the latest public release using .NET 7, and then I’ve done the minimal amount of work to get it running on .NET 8 rc2 (mostly some nullable fixes that are already in my newer v5.1 branch)
- You must have long file paths enabled for Windows, which may require a reboot, due to some source generators that end up using super long paths https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
- Load up ./paintdotnet.sln in Visual Studio 2022 17.8.0 Preview 7.0.
- Due to something I haven’t quite yet figured out with respect to project dependencies, you will first have to manually rebuild the AppVersion project. It’s at Solution Explorer -> Misc (the first node) -> AppVersion
- Now do a full rebuild
- Verify that the
DOTNET_GCStress=2
environment variable is set up in the Debug properties - Debug menu -> Start Debugging
- You will eventually (~20-60 seconds) see an
ExecutionEngineException
pop up before the app’s main window is displayed
Expected behavior
App starts up just fine, albeit very slowly due to DOTNET_GCStress=2
Actual behavior
App is not able to initialize, it dies with an EEE before the main window is displayed. On my system it’s usually somewhere in the constructor for the FileMenu
class, but there’s some random variance as to exactly where it dies.
It usually won’t even show a callstack in the debugger, and when it does it will not load symbols for the relevant .NET framework/runtime DLLs:
Regression?
Yes. This works fine if you change ./paintdotnet/paintdotnet.csproj
to target .NET 7. Just remove the <TargetFramework>
element at the top and do a full rebuild (sometimes need to do that twice after changing TargetFramework, as the first time will error due to what I think is a VS or msbuild bug). It will then revert to .NET 7 based on the values in ./TargetFramework.props
Known Workarounds
No response
Configuration
Visual Studio 2022 17.8.0 Preview 7.0 x64 .NET 8 RC2
Happens on both my desktop: Ryzen 9 7950X Windows 11 23H2 build 22635.2700
and on my Lenovo P16 laptop: Intel Core i7-12800HX Windows 11 23H2 build 22631.2506
Other information
cc @EgorBo who was commenting on this a little over on Discord, and who already has access to the dotnet/paint.net repository. Also @MichalPetryka who recommended me to file the issue
About this issue
- Original URL
- State: open
- Created 8 months ago
- Comments: 18 (18 by maintainers)
Reopening for backport
I have tried the fix proposed above and I no longer see the crash. (without the fix it always reproes for me)
I’ve tried several times - it takes quite a while (since it is with GCStress=2), but eventually we get to the UI showing up without seeing EE exceptions.
I will stage a PR for the main branch and then we can port the fix to 8.0.
@mangod9 and @VSadov, you now have access to the repository and branch if you need it (see link and instructions above)
@rickbrew I have the file.
@VSadov Did change the weak reference logic to be mostly managed last year - see https://github.com/dotnet/runtime/pull/77196. Since this is failing in the weak reference logic specifically, I think that is likely the best place to start.
Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.
Issue Details
Description
I’ve had two spurious EEE’s pop out at me while I was in the debugger over the last week, working on the new version of my app (Paint.NET v5.1) that is targeting .NET 8. I was worried it was due to my new code, some of which is clipboard related (always a bug farm) …
… But I’m now able to reproduce this 100% with my latest public release (Paint.NET v5.0.11, .NET 7.0.12), when it’s retargeted for .NET 8. It has no trouble with .NET 7.
I believe this is a new bug in .NET 8, it’s not due to any changes I’ve made in my code.
Reproduction Steps
You will need access to https://github.com/dotnet/paint.net/ – just ask and I will add you (for MSFT employees that is)
You will want this branch: https://github.com/dotnet/paint.net/tree/net8_EEE_repro . This is branched from v5.0.11, the latest public release using .NET 7, and then I’ve done the minimal amount of work to get it running on .NET 8 rc2 (mostly some nullable fixes that are already in my newer v5.1 branch)
DOTNET_GCStress=2
environment variable is set up in the Debug propertiesExecutionEngineException
pop up before the app’s main window is displayedExpected behavior
App starts up just fine, albeit very slowly due to
DOTNET_GCStress=2
Actual behavior
App is not able to initialize, it dies with an EEE before the main window is displayed. On my system it’s usually somewhere in the constructor for the
FileMenu
class, but there’s some random variance as to exactly where it dies.It usually won’t even show a callstack in the debugger, and when it does it will not load symbols for the relevant .NET framework/runtime DLLs:
Regression?
Yes. This works fine if you change
./paintdotnet/paintdotnet.csproj
to target .NET 7. Just remove the<TargetFramework>
element at the top and do a full rebuild (sometimes need to do that twice after changing TargetFramework, as the first time will error due to what I think is a VS or msbuild bug). It will then revert to .NET 7 based on the values in./TargetFramework.props
Known Workarounds
No response
Configuration
Visual Studio 2022 17.8.0 Preview 7.0 x64 .NET 8 RC2
Happens on both my desktop: Ryzen 9 7950X Windows 11 23H2 build 22635.2700
and on my Lenovo P16 laptop: Intel Core i7-12800HX Windows 11 23H2 build 22631.2506
Other information
cc @EgorBo who was commenting on this a little over on Discord, and who already has access to the dotnet/paint.net repository
area-GC-coreclr
,untriaged