Skip to content

Static method LicenseManager.Validate is not thread-safe #286

Closed
@jnm2

Description

@jnm2

A lot of tests in this suite directly or indirectly instantiate third-party controls whose constructors call LicenseManager.Validate. I'm not thrilled with having to disable parallelization for these tests.

System.InvalidOperationException : Hashtable insert failed. Load factor too high. The most common cause is multiple threads writing to the Hashtable simultaneously.
/LicenseManager.cs#L267-L327

This is also reported through https://xamarin.github.io/bugzilla-archives/45/45991/bug.html.

at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.ComponentModel.LicenseManager.CacheProvider(Type type, LicenseProvider provider)
at System.ComponentModel.LicenseManager.ValidateInternalRecursive(LicenseContext context, Type type, Object instance, Boolean allowExceptions, License& license, String& licenseKey)
at System.ComponentModel.LicenseManager.Validate(Type type, Object instance)
at DevExpress.XtraEditors.Repository.RepositoryItemTreeListLookUpEdit..ctor()

You can see the hash tables being accessed without a lock and with non-atomic operations spread across several accesses:

https://github.com/dotnet/runtime/blob/0d493082d0b33b5aa74dbdd9dc44d211d20371ab/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions