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

Memory Leak in CsdlReader.TryParse Due to missing xmlns=”http://docs.oasis-open.org/odata/ns/edm” #3188

Open
WanjohiSammy opened this issue Feb 25, 2025 · 0 comments
Assignees
Labels

Comments

@WanjohiSammy
Copy link
Member

WanjohiSammy commented Feb 25, 2025

The CsdlReader.TryParse does not throw an exception when parsing CSDL document with missing xmlns=”http://docs.oasis-open.org/odata/ns/edm”. Instead, the memory continuously increases until it reaches the maximum limit, resulting in significant memory usage. This condition persists until the operation is either forcibly stopped, canceled, or time out.

Assemblies affected

Microsoft.OData.Edm 7.x, 8.x

Reproduce steps

  • Clone the repo: https://github.com/WanjohiSammy/MemoryLeakInCSDLReaderTryParse.git

  • Run the application:

    • Remove xmlns="http://docs.oasis-open.org/odata/ns/edm" from the Schema tag and run the application
    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
     <edmx:DataServices>
         <Schema Namespace="NS"> // without xmlns="http://docs.oasis-open.org/odata/ns/edm"
             <EntityType Name="Customer">
                 <Key>
                     <PropertyRef Name="Id" />
                 </Key>
                 <Property Name="Id" Type="Edm.Int32" Nullable="false" />
                 <Property Name="Name" Type="Edm.String" />
             </EntityType>
             <EntityContainer Name="Container">
                 <EntitySet Name="Customers" EntityType="NS.Customer" />
             </EntityContainer>
         </Schema>
     </edmx:DataServices>
    </edmx:Edmx>
    • Note how the process memory is growing using Visual Studio Diagnostics Tools

    Image

    • with <Schema xmlns=""http://docs.oasis-open.org/odata/ns/edm"" Namespace=""NS"">, the CSDL document is parsed successfully
    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
     <edmx:DataServices>
         <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="NS"> // with xmlns
             <EntityType Name="Customer">
                 <Key>
                     <PropertyRef Name="Id" />
                 </Key>
                 <Property Name="Id" Type="Edm.Int32" Nullable="false" />
                 <Property Name="Name" Type="Edm.String" />
             </EntityType>
             <EntityContainer Name="Container">
                 <EntitySet Name="Customers" EntityType="NS.Customer" />
             </EntityContainer>
         </Schema>
     </edmx:DataServices>
    </edmx:Edmx>

Expected result

Schema without xmlns="http://docs.oasis-open.org/odata/ns/edm" should throw an exception or should be captured as part of EdmError instead of running to forever and increases memory usage.

Actual result

The memory continuously increases until it reaches the maximum limit, resulting in significant memory usage. This condition persists until the operation is either forcibly stopped, canceled, or time out.

Additional detail

Optional, details of the root cause if known. Delete this section if you have no additional details to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant