ASP.NET service Segmentation fault in Docker container with .NET 6.0
Description
I am not sure if this is a sqlclient issue, however the patch they released (4.0.1) did not solve my problem. The details are given in the issue below: https://github.com/dotnet/SqlClient/issues/1480 So I am wondering if there is some other issue.
Exception message:
Starting application
Building host
2022-01-18 09:14:12.86315-05:00|INFO|Elliott.CollateralMgmt.Api.Service.ApiService.Start||Running host|
2022-01-18 09:14:12.94390-05:00|DEBUG|Microsoft.Extensions.Hosting.Internal.HostingLoggerExtensions.Starting||Hosting starting|
2022-01-18 09:14:13.05861-05:00|DEBUG|Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderFactory..ctor||Registered model binder providers, in the following order: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.HeaderModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FloatingPointTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.EnumTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DateTimeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CancellationTokenModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormFileModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.KeyValuePairModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DictionaryModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexObjectModelBinderProvider|
2022-01-18 09:14:13.29288-05:00|DEBUG|Microsoft.AspNetCore.SignalR.Internal.DefaultHubProtocolResolver..ctor||Registered SignalR Protocol: json, implemented by Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol.|
2022-01-18 09:14:13.34641-05:00|TRACE|Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.DiscoverHubMethods||'LiveUpdateSource' hub method 'SendMessageAsync' is bound.|
Segmentation fault
Reproduction Steps
Microsoft.Data.SqlClient version:4.0.1 .NET target: 6 (upgrading from Core 3.1) SQL Server version: 2022 Operating system: Docker container ASP NET application fails to start up in Linux Docker container only.
Expected behavior
Service should start
Actual behavior
Segmentation fault
Regression?
No response
Known Workarounds
public static class NetSecurityNativeFix
{
public static void Initialize()
{
var result = -1;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
result = NetSecurityNative_EnsureGssInitialized();
}
if (result is 0)
{
Console.WriteLine($"{nameof(NetSecurityNativeFix)}::{nameof(Initialize)} EnsureGssInitialized workaround succeeded");
}
else
{
Console.WriteLine($"{nameof(NetSecurityNativeFix)}::{nameof(Initialize)} EnsureGssInitialized has failed result {result}");
}
}
[System.Runtime.InteropServices.DllImport("System.Net.Security.Native")]
[System.Runtime.InteropServices.DefaultDllImportSearchPaths(System.Runtime.InteropServices.DllImportSearchPath.UserDirectories)]
private static extern int NetSecurityNative_EnsureGssInitialized();
}
There is a temporary solution that works, by calling Initialize() as the first thing in Program.cs
Configuration
No response
Other information
No response
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @dotnet/ncl, @vcsjones See info in area-owners.md if you want to be subscribed.
Issue Details
Description
I am not sure if this is a sqlclient issue, however the patch they released (4.0.1) did not solve my problem. The details are given in the issue below: https://github.com/dotnet/SqlClient/issues/1480 So I am wondering if there is some other issue.
Exception message:
Starting application
Building host
2022-01-18 09:14:12.86315-05:00|INFO|Elliott.CollateralMgmt.Api.Service.ApiService.Start||Running host|
2022-01-18 09:14:12.94390-05:00|DEBUG|Microsoft.Extensions.Hosting.Internal.HostingLoggerExtensions.Starting||Hosting starting|
2022-01-18 09:14:13.05861-05:00|DEBUG|Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderFactory..ctor||Registered model binder providers, in the following order: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.HeaderModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FloatingPointTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.EnumTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DateTimeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CancellationTokenModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormFileModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.KeyValuePairModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DictionaryModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexObjectModelBinderProvider|
2022-01-18 09:14:13.29288-05:00|DEBUG|Microsoft.AspNetCore.SignalR.Internal.DefaultHubProtocolResolver..ctor||Registered SignalR Protocol: json, implemented by Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol.|
2022-01-18 09:14:13.34641-05:00|TRACE|Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.DiscoverHubMethods||'LiveUpdateSource' hub method 'SendMessageAsync' is bound.|
Segmentation fault
Reproduction Steps
Microsoft.Data.SqlClient version:4.0.1 .NET target: 6 (upgrading from Core 3.1) SQL Server version: 2022 Operating system: Docker container ASP NET application fails to start up in Linux Docker container only.
Expected behavior
Service should start
Actual behavior
Segmentation fault
Regression?
No response
Known Workarounds
public static class NetSecurityNativeFix
{
public static void Initialize()
{
var result = -1;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
result = NetSecurityNative_EnsureGssInitialized();
}
if (result is 0)
{
Console.WriteLine($"{nameof(NetSecurityNativeFix)}::{nameof(Initialize)} EnsureGssInitialized workaround succeeded");
}
else
{
Console.WriteLine($"{nameof(NetSecurityNativeFix)}::{nameof(Initialize)} EnsureGssInitialized has failed result {result}");
}
}
[System.Runtime.InteropServices.DllImport("System.Net.Security.Native")]
[System.Runtime.InteropServices.DefaultDllImportSearchPaths(System.Runtime.InteropServices.DllImportSearchPath.UserDirectories)]
private static extern int NetSecurityNative_EnsureGssInitialized();
}
There is a temporary solution that works, by calling Initialize() as the first thing in Program.cs
Configuration
No response
Other information
No response
| Author: | meghma |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
Related to #60906
@wfurt
#60906 refers to https://github.com/dotnet/SqlClient/issues/1390 but the patch from that issue was SqlClient 4.0.1 that has not solved the problem. @jkotas @wfurt
If the the workaround works e.g. this is truly missing Initialization I see no reason why the update would not work - as the SQL fix is essentially the same. Are you sure @meghma your project is really updated? You can follow steps from the linked issue and get stack trace from the crash with lldb.
This issue has been marked needs-author-action since it may be missing important information. Please refer to our contribution guidelines for tips on how to report issues effectively.
Triage: No response for 2+ weeks. Closing. If there is evidence the fix didn't work in all cases, please feel free to reopen there (SqlClient).