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

SDSUtils.BuildDirectoryEntry( "LDAP://" + this.dnsHostName + "/" + this.defaultNamingContext, this.credentials, this.authTypes) is not disposed at the end of the function #94775

Closed
achufistov opened this issue Nov 15, 2023 · 3 comments

Comments

@achufistov
Copy link

Description

dotnet 6.0

File: /src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs:2526

Problem: SDSUtils.BuildDirectoryEntry( "LDAP://" + this.dnsHostName + "/" + this.defaultNamingContext, this.credentials, this.authTypes) is not disposed at the end of the function

Reproduction Steps

  1. Role: detected
    detected
    [ADStoreCtx.cs:[2526:0]]

  2. Role: tracepoint
    2.1 Step 1: Entering the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.2 Step 2: Condition component.Length > 3 taking any branch
    [ADStoreCtx.cs:[2463:26]]
    2.3 Step 3: Entering the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.4 Step 4: Condition component.Length > 3 taking any branch
    [ADStoreCtx.cs:[2463:26]]
    2.5 Step 5: Entering the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.6 Step 6: Condition component.Length > 3 taking any branch
    [ADStoreCtx.cs:[2463:26]]
    2.7 Step 7: Exiting the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.8 Step 8: Condition ncComponents is null taking any branch
    [ADStoreCtx.cs:[2460:46]]
    2.9 Step 9: Condition dnsDomainName.Length > 0 taking true branch
    [ADStoreCtx.cs:[2474:21]]
    2.10 Step 10: Condition rootDse = new DirectoryEntry("LDAP://" + this.dnsHostName + "/rootDse", "", "", AuthenticationTypes.Anonymous) is null taking any branch
    [ADStoreCtx.cs:[2449:35]]
    2.11 created in method System.DirectoryServices.AccountManagement.SDSUtils.BuildDirectoryEntry(string, System.DirectoryServices.AccountManagement.NetCred, System.DirectoryServices.AuthenticationTypes)
    [ADStoreCtx.cs:[2526:39]]
    2.12 assigned
    [ADStoreCtx.cs:[2526:28]]
    2.13 no escape
    [ADStoreCtx.cs:[2532:13]]
    2.14 no escape
    [ADStoreCtx.cs:[2534:17]]
    2.15 Step 11: Condition domainNC.Properties["lockoutDuration"].Count > 0 taking true branch
    [ADStoreCtx.cs:[2534:17]]
    2.16 no escape
    [ADStoreCtx.cs:[2536:30]]
    2.17 no escape
    [ADStoreCtx.cs:[2537:110]]

  3. Role: debug
    3.1 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2435:37]]
    3.2 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2478:41]]
    3.3 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.4 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2514:37]]
    3.5 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2542:41]]
    3.6 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2556:41]]
    3.7 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2563:45]]
    3.8 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.9 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2478:41]]
    3.10 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.11 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2514:37]]
    3.12 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2542:41]]
    3.13 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2556:41]]
    3.14 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2563:45]]
    3.15 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2478:41]]
    3.16 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.17 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2514:37]]
    3.18 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2542:41]]
    3.19 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2556:41]]
    3.20 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2563:45]]

Expected behavior

memory leak

Actual behavior

memory leak

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

Found by Linux Verification Center (linuxtesting.org) with SVACE.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 15, 2023
@ghost
Copy link

ghost commented Nov 15, 2023

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

Issue Details

Description

dotnet 6.0

File: /src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs:2526

Problem: SDSUtils.BuildDirectoryEntry( "LDAP://" + this.dnsHostName + "/" + this.defaultNamingContext, this.credentials, this.authTypes) is not disposed at the end of the function

Reproduction Steps

  1. Role: detected
    detected
    [ADStoreCtx.cs:[2526:0]]

  2. Role: tracepoint
    2.1 Step 1: Entering the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.2 Step 2: Condition component.Length > 3 taking any branch
    [ADStoreCtx.cs:[2463:26]]
    2.3 Step 3: Entering the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.4 Step 4: Condition component.Length > 3 taking any branch
    [ADStoreCtx.cs:[2463:26]]
    2.5 Step 5: Entering the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.6 Step 6: Condition component.Length > 3 taking any branch
    [ADStoreCtx.cs:[2463:26]]
    2.7 Step 7: Exiting the foreach
    [ADStoreCtx.cs:[2460:46]]
    2.8 Step 8: Condition ncComponents is null taking any branch
    [ADStoreCtx.cs:[2460:46]]
    2.9 Step 9: Condition dnsDomainName.Length > 0 taking true branch
    [ADStoreCtx.cs:[2474:21]]
    2.10 Step 10: Condition rootDse = new DirectoryEntry("LDAP://" + this.dnsHostName + "/rootDse", "", "", AuthenticationTypes.Anonymous) is null taking any branch
    [ADStoreCtx.cs:[2449:35]]
    2.11 created in method System.DirectoryServices.AccountManagement.SDSUtils.BuildDirectoryEntry(string, System.DirectoryServices.AccountManagement.NetCred, System.DirectoryServices.AuthenticationTypes)
    [ADStoreCtx.cs:[2526:39]]
    2.12 assigned
    [ADStoreCtx.cs:[2526:28]]
    2.13 no escape
    [ADStoreCtx.cs:[2532:13]]
    2.14 no escape
    [ADStoreCtx.cs:[2534:17]]
    2.15 Step 11: Condition domainNC.Properties["lockoutDuration"].Count > 0 taking true branch
    [ADStoreCtx.cs:[2534:17]]
    2.16 no escape
    [ADStoreCtx.cs:[2536:30]]
    2.17 no escape
    [ADStoreCtx.cs:[2537:110]]

  3. Role: debug
    3.1 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2435:37]]
    3.2 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2478:41]]
    3.3 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.4 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2514:37]]
    3.5 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2542:41]]
    3.6 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2556:41]]
    3.7 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2563:45]]
    3.8 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.9 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2478:41]]
    3.10 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.11 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2514:37]]
    3.12 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2542:41]]
    3.13 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2556:41]]
    3.14 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2563:45]]
    3.15 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2478:41]]
    3.16 System.ComponentModel.Component.Dispose() invocation is a back edge
    [ADStoreCtx.cs:[2449:35]]
    3.17 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2514:37]]
    3.18 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2542:41]]
    3.19 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2556:41]]
    3.20 System.DirectoryServices.AccountManagement.GlobalDebug.Info.get invocation is a back edge
    [ADStoreCtx.cs:[2563:45]]

Expected behavior

memory leak

Actual behavior

memory leak

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Author: achufistov
Assignees: -
Labels:

area-System.DirectoryServices, untriaged

Milestone: -

@achufistov
Copy link
Author

I would like to suggest a pull request.

@buyaa-n
Copy link
Contributor

buyaa-n commented Jan 17, 2024

Looks simple fix, can be covered with #94772, closing as duplicate

@buyaa-n buyaa-n closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants