runtime: Unhandled exception inside Interop+OpenSsl.AlpnServerSelectCallback causing the process crash
Description
Unhandled exception which causes process to crash
System.InvalidOperationException: Handle is not initialized.
Stack trace:
in System.Void System.ThrowHelper.ThrowInvalidOperationException_HandleIsNotInitialized()
in System.Runtime.InteropServices.GCHandle System.Runtime.InteropServices.GCHandle.FromIntPtr(System.IntPtr)
in System.Int32 Interop+OpenSsl.AlpnServerSelectCallback(System.IntPtr, System.Byte**, System.Byte*, System.Byte*, System.UInt32, System.IntPtr)
Reproduction Steps
It reproduces sometimes (but extremely rarely) in ASP.NET Core app running on Ubuntu 18:04 Server after we migrated from .NET 6 to .NET 7 It uses Kestrel + SSL certificate for HTTPS
Expected behavior
Actual behavior
Process crashes
Regression?
Maybe .NET 7.0 regression
Known Workarounds
No response
Configuration
uname -a Linux tll-netem-1 5.4.0-87-lowlatency #98~18.04.1-Ubuntu SMP PREEMPT Wed Sep 22 13:43:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
dotnet --info .NET SDK: Version: 7.0.102 Commit: 4bbdd14480
Runtime Environment: OS Name: ubuntu OS Version: 18.04 OS Platform: Linux RID: ubuntu.18.04-x64 Base Path: /usr/share/dotnet/sdk/7.0.102/
Host: Version: 7.0.2 Architecture: x64 Commit: d037e070eb
.NET SDKs installed: 5.0.408 [/usr/share/dotnet/sdk] 6.0.405 [/usr/share/dotnet/sdk] 7.0.102 [/usr/share/dotnet/sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 5.0.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.17 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found: None
Environment variables: Not set
global.json file: Not found
Other information
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 38 (33 by maintainers)
@rzikm I don’t have a simpler repro, only that I observe it happening several times per day on a server that gets a lot of traffic. I can try the fix, and see if it helps.
I checked it briefly but did not uncover the root cause yet, I would need to set it up in a way I can examine openssl structures. Since the problem seems to go away with the bandaid fix, we will postpone deeper investigation until we are done with more urgent stuff.
@karelz , I tried it and it seems it fixes the problem. At least I didn’t have crashes for almost a week. Before it crashed every 2 days
It’s run for ~48 hours now, and no problems.
@karelz I’ve deployed with it now, no problems yet (it’s run for an hour). Prior to this, the server crashed 6 times in 3 days after upgrading to net 7. So if this fix runs without problems for some days it should strengthen the argument that the fix is helpful. I’ll come back here with an update when it has run for longer.
@karelz , yes, I’m willing to help you to debug the issue. B.T.W. I also shared the crash dump with @rzikm & @wfurt, did you have a chance to look into it?
@karelz , yes
@karelz,
@rzikm, I’ll try your fix