Skip to content
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

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 opened this issue Sep 22, 2023 · 9 comments
Labels
area-System.Net.Sockets needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity
Milestone

Comments

@niravjprabtani
Copy link

niravjprabtani commented Sep 22, 2023

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 ghost added the untriaged New issue has not been triaged by the area owner label Sep 22, 2023
@ghost
Copy link

ghost commented Sep 22, 2023

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.<SendAsync>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.<SendAsync>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.<GetTrustBundleWithRetry>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.<SendAsync>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
Copy link
Member

karelz commented Sep 22, 2023

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
Copy link

ghost commented Sep 22, 2023

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.<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.

Author: niravjprabtani
Assignees: -
Labels:

area-System.Net.Sockets, untriaged

Milestone: -

@antonfirsov
Copy link
Member

antonfirsov commented Sep 22, 2023

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:

private static readonly int s_nativePathOffset = 2; // sizeof(sun_family)
private static readonly int s_nativePathLength = 108; // sizeof(sun_path)
private static readonly int s_nativeAddressSize = s_nativePathOffset + s_nativePathLength; // sizeof(sockaddr_un)

@wfurt any thoughts?

@antonfirsov antonfirsov added this to the 9.0.0 milestone Sep 22, 2023
@antonfirsov antonfirsov removed the untriaged New issue has not been triaged by the area owner label Sep 22, 2023
@antonfirsov
Copy link
Member

antonfirsov commented Sep 22, 2023

@niravjprabtani what hardware/architecture is this running on? What is the exact OS version? As stated in #92464 (comment), 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
Copy link
Member

wfurt commented Sep 22, 2023

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.

@antonfirsov antonfirsov added the needs-author-action An issue or pull request that requires more info or actions from the author. label Sep 25, 2023
@ghost
Copy link

ghost commented Sep 25, 2023

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

@ghost ghost added the no-recent-activity label Oct 9, 2023
@ghost
Copy link

ghost commented Oct 9, 2023

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
Copy link

ghost commented Oct 24, 2023

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.

@ghost ghost closed this as completed Oct 24, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 23, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Sockets needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity
Projects
None yet
Development

No branches or pull requests

5 participants