Skip to content

Stack Overflow with new cloning changes #1212

Closed

Description

@baywet

1.6.4-preview2 (just released earlier) produces stack overflows. Running dotnet test in this PR triggers the behavior. The DictionaryCloneHelper is probably missing some exist conditions.

at Microsoft.OpenApi.Models.OpenApiSchema..ctor(Microsoft.OpenApi.Models.OpenApiSchema)
   at Microsoft.OpenApi.Models.OpenApiMediaType..ctor(Microsoft.OpenApi.Models.OpenApiMediaType)
   at DynamicClass.InvokeStub_OpenApiMediaType..ctor(System.Object, System.Object, IntPtr*)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<System.__Canon,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiResponse..ctor(Microsoft.OpenApi.Models.OpenApiResponse)
   at DynamicClass.InvokeStub_OpenApiResponse..ctor(System.Object, System.Object, IntPtr*)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<System.__Canon,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiResponses..ctor(Microsoft.OpenApi.Models.OpenApiResponses)
   at Microsoft.OpenApi.Models.OpenApiOperation..ctor(Microsoft.OpenApi.Models.OpenApiOperation)
   at DynamicClass.InvokeStub_OpenApiOperation..ctor(System.Object, System.Object, IntPtr*)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[Microsoft.OpenApi.Models.OperationType, Microsoft.OpenApi, Version=1.6.4.0, Culture=neutral, PublicKeyToken=3f5743946376f042],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<Microsoft.OpenApi.Models.OperationType,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiPathItem..ctor(Microsoft.OpenApi.Models.OpenApiPathItem)
   at DynamicClass.InvokeStub_OpenApiPathItem..ctor(System.Object, System.Object, IntPtr*)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<System.__Canon,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiPaths..ctor(Microsoft.OpenApi.Models.OpenApiPaths)
   at Microsoft.OpenApi.Models.OpenApiDocument..ctor(Microsoft.OpenApi.Models.OpenApiDocument)
   at Microsoft.OpenApi.Models.OpenApiReference..ctor(Microsoft.OpenApi.Models.OpenApiReference)
--------------------------------
   at Microsoft.OpenApi.Models.OpenApiSchema..ctor(Microsoft.OpenApi.Models.OpenApiSchema)
   at Microsoft.OpenApi.Models.OpenApiMediaType..ctor(Microsoft.OpenApi.Models.OpenApiMediaType)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<System.__Canon,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiResponse..ctor(Microsoft.OpenApi.Models.OpenApiResponse)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<System.__Canon,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiResponses..ctor(Microsoft.OpenApi.Models.OpenApiResponses)
   at Microsoft.OpenApi.Models.OpenApiOperation..ctor(Microsoft.OpenApi.Models.OpenApiOperation)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
   at System.Reflection.ConstructorInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.OpenApi.Helpers.DictionaryCloneHelper.Clone[[Microsoft.OpenApi.Models.OperationType, Microsoft.OpenApi, Version=1.6.4.0, Culture=neutral, PublicKeyToken=3f5743946376f042],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IDictionary`2<Microsoft.OpenApi.Models.OperationType,System.__Canon>)
   at Microsoft.OpenApi.Models.OpenApiPathItem..ctor(Microsoft.OpenApi.Models.Open

Test Run Aborted with error System.Exception: One or more errors occurred.
 ---> System.Exception: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
 ---> System.Exception: An existing connection was forcibly closed by the remote host.
   at System.Net.Sockets.NetworkStream.Read(Span`1 buffer)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Span`1 buffer)
   at System.Net.Sockets.NetworkStream.ReadByte()
   at System.IO.BinaryReader.Read7BitEncodedInt()
   at System.IO.BinaryReader.ReadString()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action`1 errorHandler, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---.

Activity

  1. added
    type:bugA broken experience
    priority:p0Blocking issue/ loss of critical functions. An ICM may be filed to communicate urgency. SLA<=48hrs
    bug-fix-vNextBug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR.
    on Apr 11, 2023
  2. baywet commented on Apr 12, 2023

    @baywet
    MemberAuthor

    Maggie Kimani (@MaggieKimani1) as I suspected the fix we just released is not addressing the issue. Can you take another look at this please and make sure you test by running "dotnet test" on this PR content with a local reference to OpenAPI.net please?

    dotnet remove src/Kiota.Builder/Kiota.Builder.csproj package Microsoft.OpenApi
    dotnet remove src/Kiota.Builder/Kiota.Builder.csproj package Microsoft.OpenApi.Readers
    dotnet add src/Kiota.Builder/Kiota.Builder.csproj reference <pathToOpenApiCSproj>
    dotnet add src/Kiota.Builder/Kiota.Builder.csproj reference <pathToOpenApiReadersCSproj>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug-fix-vNextBug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR.priority:p0Blocking issue/ loss of critical functions. An ICM may be filed to communicate urgency. SLA<=48hrstype:bugA broken experiencetype:regressionA bug from previous release

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions