Skip to content

NullReferenceException in ConditionalWeakTable`2.Remove #85980

Open
@mattleibow

Description

@mattleibow

Description

I am working on a PR here: https://github.com/dotnet/maui/pull/14846/files and I see a test failure that is an exception inside ConditionalWeakTable. I am semi-sure that my changes don't have anything to do with it and the test that is failing does not really use anything that I am working on.

However, since this is an exception inside CWT, I think that there may be an issue there at least:

System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at System.Runtime.CompilerServices.ConditionalWeakTable`2.Remove(TKey key)

https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs#L159

As far as I can see, the only things in that Remove method that can be null is _container... Bu that should not be null, so this is scary-ish.

Reproduction Steps

This is the hard part and I am trying to find something.

Expected behavior

No exception.

Actual behavior

Exception.

Regression?

No response

Known Workarounds

No response

Configuration

.NET 7.0.201 on macOS. Seems to work fine on Windows.

Onlyfailing on CI, cannot reproduce this on local Windows/macOS.

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtime.CompilerServicesenhancementProduct code improvement that does NOT require public API changes/additionsneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions