dotnet / runtime

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

System.Net.Sockets.SocketException (10014): The system detected an invalid pointer address in attempting to use a pointer argument in a call #92464

Closed niravjprabtani closed 10 months ago

niravjprabtani commented 11 months ago

Description

I've created an IoTEdge module, which is an application containerized using Docker, and initially, it was built with dotnet core version 3.1. We've been using this module for a considerable amount of time. However, as part of our security team's recommendations, we decided to migrate it to dotnet core version 7.0. After making this migration, we encountered a System.Net.Socket.SocketException when running the modules. We attempted to test it with dotnet core 6.0 as well, but unfortunately, we faced the same issue. Consequently, we reverted the Docker base image back to version 3.1, and the module started functioning correctly.

We uses following docker image for our application FROM mcr.microsoft.com/dotnet/sdk:7.0

I'm sharing the exception details for additional information.

{
    "logsource":"ddiotdevicehostmodule",
    "logdata":"Message:-Initializing IoT Hub module client;CallingMemberName:-Init",
    "loglevel":2,
    "logtype":4,
    "logtime":"2023-09-21T05:13:20.8909851+00:00",
    "correlationId":null
},
{
    "logsource":"ddiotdevicehostmodule",
    "logdata":
"Message:-Exception while initializing the module;CallingMemberName:-Init;Exception:-System.Net.Sockets.SocketException (10014): The system detected an invalid pointer address in attempting to use a pointer argument in a call.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ConnectAsync(Socket socket)
   at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()
   at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.<>c__DisplayClass3_0.<GetTrustBundleWithRetry>b__0()
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.AsyncExecution`1.ExecuteAsyncImpl(Task ignore)
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.AsyncExecution`1.ExecuteAsync()
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.ExecuteAsync[TResult](Func`1 taskFunc, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.ExecuteAsync[TResult](Func`1 taskFunc)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion)
   at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()
   at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateAsync()
   at Microsoft.Azure.Devices.Client.ModuleClient.CreateFromEnvironmentAsync(ITransportSettings[] transportSettings, ClientOptions options)
   at DDIoTDeviceHostModule.Program.Init() in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 150
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at DDIoTDeviceHostModule.Program.Init()
   at DDIoTDeviceHostModule.Program.Main(String[] args) in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 117
--- End of stack trace from previous location ---
   at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()\r\n   at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion)
   at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion)
   at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()
   at DDIoTDeviceHostModule.Program.Init() in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 150",
    "loglevel":4,
    "logtype":4,
    "logtime":"2023-09-21T05:13:21.0433225+00:00",
    "correlationId":null
},

Reproduction Steps

We are not able to upgrade the application to latest dotnet core version although it works fine with dotnet core 3.1, No specific steps for reproduction

Expected behavior

Application should work as is as they works in dotnet core 3.1

Actual behavior

It gives an exceptions

Regression?

No response

Known Workarounds

No workarounds with dotnet core 7.0

Configuration

Dotnet Core 7.0 Docker Windows X64

Other information

We are using iotedge device sdk to initialize the modules. While initializing the modules we are getting this exception.

ghost commented 11 months ago

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

Issue Details
### Description I've created an IoTEdge module, which is an application containerized using Docker, and initially, it was built with dotnet core version 3.1. We've been using this module for a considerable amount of time. However, as part of our security team's recommendations, we decided to migrate it to dotnet core version 7.0. After making this migration, we encountered a System.Net.Socket.SocketException when running the modules. We attempted to test it with dotnet core 6.0 as well, but unfortunately, we faced the same issue. Consequently, we reverted the Docker base image back to version 3.1, and the module started functioning correctly. I'm sharing the exception details for additional information. ``` {"logsource":"ddiotdevicehostmodule","logdata":"Message:-Initializing IoT Hub module client;CallingMemberName:-Init","loglevel":2,"logtype":4,"logtime":"2023-09-21T05:13:20.8909851+00:00","correlationId":null}, {"logsource":"ddiotdevicehostmodule","logdata":"Message:-Exception while initializing the module;CallingMemberName:-Init;Exception:-System.Net.Sockets.SocketException (10014): The system detected an invalid pointer address in attempting to use a pointer argument in a call.\r\n at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)\r\n at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ConnectAsync (Socket socket)\r\n at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP, CancellationToken cancellationToken)\r\n at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP)\r\n at Microsoft.Azure.Devices.Client.HsmAuthent ication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication .Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at Syst em.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, Cancella tionToken cancellationToken)\r\n at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingR equestsCts, CancellationToken originalCancellationToken)\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at System.Net.Http.HttpClient.g__Core|83_0(HttpRe questMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)\r\n at System.Net.Http.HttpClient.Se ndAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, Ca ncellationToken cancellationToken)\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.Tr ustBundleAsync(String api_version, CancellationToken cancellationToken)\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version)\r\n at Microsoft.Azure.Devices.Client.Ed ge.TrustBundleProvider.<>c__DisplayClass3_0.b__0()\r\n at Microsoft.Azure.Devices.Client.TransientFaultHandling.AsyncExecution`1.ExecuteAsyncImpl(Task ignore)\r\n at Microsoft.Azure.Devices.Client.TransientFa ultHandling.AsyncExecution`1.ExecuteAsync()\r\n at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.ExecuteAsync[TResult](Func`1 taskFunc, CancellationToken cancellationToken)\r\n at Microsoft.Azure.Devices.Client.Tr ansientFaultHandling.RetryPolicy.ExecuteAsync[TResult](Func`1 taskFunc)\r\n at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion)\r\n at System.Runtime.Comp ilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion)\r\n at Micro soft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion)\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microso ft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion)\r\n at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()\r\n at System.Runt ime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()\r\n at Microsoft.Azure.Device s.Client.Edge.EdgeModuleClientFactory.CreateAsync()\r\n at Microsoft.Azure.Devices.Client.ModuleClient.CreateFromEnvironmentAsync(ITransportSettings[] transportSettings, ClientOptions options)\r\n at DDIoTDeviceHostModule.Program.Ini t() in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 150\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n a t DDIoTDeviceHostModule.Program.Init()\r\n at DDIoTDeviceHostModule.Program.Main(String[] args) in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 117\r\n--- End of stack trace f rom previous location ---\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendA sync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean dis poseCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToke n cancellationToken)\r\n at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion)\r\n at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundle Async(Uri providerUri, String apiVersion)\r\n at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync()\r\n at DDIoTDeviceHostModule.Program.Init() in W:\\NEW-WorkSpace\\ready\\mi-digit al-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 150","loglevel":4,"logtype":4,"logtime":"2023-09-21T05:13:21.0433225+00:00","correlationId":null}, ``` ### Reproduction Steps We are not able to upgrade the application to latest dotnet core version although it works fine with dotnet core 3.1, No specific steps for reproduction ### Expected behavior Application should work as is as they works in dotnet core 3.1 ### Actual behavior It gives an exceptions ### Regression? _No response_ ### Known Workarounds No workarounds with dotnet core 7.0 ### Configuration Dotnet Core 7.0 Docker Windows X64 ### Other information We are using iotedge device sdk to initialize the modules. While initializing the modules we are getting this exception.
Author: niravjprabtani
Assignees: -
Labels: `area-System.Net.Http`, `untriaged`
Milestone: -
karelz commented 11 months ago

Be aware that .NET Core 3.1 is out of support for almost a year now: https://github.com/dotnet/core/blob/main/releases.md#end-of-life-net-versions

Can you confirm that it reproduces always?

Source code reference: Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync

Are you using latest version of azure-iot-sdk? (whichever the version is) Are you able to try it with .NET 8.0 RC1?

Are you able to create minimal repro? (i.e. remove as much code as you can to keep it still failing)

ghost commented 11 months ago

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

Issue Details
### Description I've created an IoTEdge module, which is an application containerized using Docker, and initially, it was built with dotnet core version 3.1. We've been using this module for a considerable amount of time. However, as part of our security team's recommendations, we decided to migrate it to dotnet core version 7.0. After making this migration, we encountered a System.Net.Socket.SocketException when running the modules. We attempted to test it with dotnet core 6.0 as well, but unfortunately, we faced the same issue. Consequently, we reverted the Docker base image back to version 3.1, and the module started functioning correctly. We uses following docker image for our application **FROM mcr.microsoft.com/dotnet/sdk:7.0** I'm sharing the exception details for additional information. ``` { "logsource":"ddiotdevicehostmodule", "logdata":"Message:-Initializing IoT Hub module client;CallingMemberName:-Init", "loglevel":2, "logtype":4, "logtime":"2023-09-21T05:13:20.8909851+00:00", "correlationId":null }, { "logsource":"ddiotdevicehostmodule", "logdata": "Message:-Exception while initializing the module;CallingMemberName:-Init;Exception:-System.Net.Sockets.SocketException (10014): The system detected an invalid pointer address in attempting to use a pointer argument in a call. at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ConnectAsync(Socket socket) at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP, CancellationToken cancellationToken) at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP) at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync() at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToken cancellationToken) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.<>c__DisplayClass3_0.b__0() at Microsoft.Azure.Devices.Client.TransientFaultHandling.AsyncExecution`1.ExecuteAsyncImpl(Task ignore) at Microsoft.Azure.Devices.Client.TransientFaultHandling.AsyncExecution`1.ExecuteAsync() at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.ExecuteAsync[TResult](Func`1 taskFunc, CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.ExecuteAsync[TResult](Func`1 taskFunc) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion) at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync() at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateAsync() at Microsoft.Azure.Devices.Client.ModuleClient.CreateFromEnvironmentAsync(ITransportSettings[] transportSettings, ClientOptions options) at DDIoTDeviceHostModule.Program.Init() in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 150 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at DDIoTDeviceHostModule.Program.Init() at DDIoTDeviceHostModule.Program.Main(String[] args) in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 117 --- End of stack trace from previous location --- at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.GetConnectedSocketAsync()\r\n at Microsoft.Azure.Devices.Client.HsmAuthentication.Transport.HttpUdsMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.Azure.Devices.Client.HsmAuthentication.GeneratedCode.HttpHsmClient.TrustBundleAsync(String api_version, CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleWithRetry(HttpHsmClient hsmHttpClient, String apiVersion) at Microsoft.Azure.Devices.Client.Edge.TrustBundleProvider.GetTrustBundleAsync(Uri providerUri, String apiVersion) at Microsoft.Azure.Devices.Client.Edge.EdgeModuleClientFactory.CreateInternalClientFromEnvironmentAsync() at DDIoTDeviceHostModule.Program.Init() in W:\\NEW-WorkSpace\\ready\\mi-digital-edge\\src\\DDIoTEdgeModules\\DDIoTDeviceHostModule\\Program.cs:line 150", "loglevel":4, "logtype":4, "logtime":"2023-09-21T05:13:21.0433225+00:00", "correlationId":null }, ``` ### Reproduction Steps We are not able to upgrade the application to latest dotnet core version although it works fine with dotnet core 3.1, No specific steps for reproduction ### Expected behavior Application should work as is as they works in dotnet core 3.1 ### Actual behavior It gives an exceptions ### Regression? _No response_ ### Known Workarounds No workarounds with dotnet core 7.0 ### Configuration Dotnet Core 7.0 Docker Windows X64 ### Other information We are using iotedge device sdk to initialize the modules. While initializing the modules we are getting this exception.
Author: niravjprabtani
Assignees: -
Labels: `area-System.Net.Sockets`, `untriaged`
Milestone: -
antonfirsov commented 11 months ago

I would suspect that WSAEFAULT is happening because WSAConnect doesn't like the sockaddr buffer passed to it for some reason.

@niravjprabtani do you know if this is running against the NETSTANDARD2_0 build of the Azure SDK?

https://github.com/Azure/azure-iot-sdk-csharp/blob/a84c614e98fd2259a965e7385b92c6d96043de57/iothub/device/src/ModernDotNet/HsmAuthentication/Transport/HttpUdsMessageHandler.cs#L56-L60

Their built in UnixDomainSocketEndPoint seems to have the size of 93 which is wrong on Windows:

https://github.com/Azure/azure-iot-sdk-csharp/blob/a84c614e98fd2259a965e7385b92c6d96043de57/iothub/device/src/ModernDotNet/HsmAuthentication/Transport/UnixDomainSocketEndPoint.cs#L19-L23

It should be 110:

https://github.com/dotnet/runtime/blob/913231acc359c5e94d4397e8fe0c8a38ae6b0c5a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Windows.cs#L10-L12

@wfurt any thoughts?

antonfirsov commented 11 months ago

@niravjprabtani what hardware/architecture is this running on? What is the exact OS version? As stated in https://github.com/dotnet/runtime/issues/92464#issuecomment-1731166841, a repro would really help a lot.

Also: did you update the IoT SDK together with the 3.1->6.0 update? We would need to know the SDK versions before/after. (ConnectAsync(EndPoint) didn't exist on 3.1, there must have been some other code running.)

wfurt commented 11 months ago

I think the UDS size would matter only if we are reaching the file length limits. If this is reproducible, it may worth of trying to get coredump And use runtime's build-in type. Even there, there were some more fixes in 8.0 and it may be worth of shoot.

ghost commented 11 months ago

This issue has been marked needs-author-action and may be missing some important information.

ghost commented 11 months ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

ghost commented 10 months ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.