Skip to content

Race conditions affecting JsonMapper and its usage of static members w/o synchronization #143

@udlose

Description

@udlose

There are several members in the JsonMapper class that are static IDictionary<T> instances. A few are only ever written to during static initialization (which is fine) and thus do not require synchronization. However, there are a few which are mutable and cause synchronization errors.

I've experienced these synchronization issues thru AWSXRayRecorder's usage of your library (aws/aws-xray-sdk-dotnet#282). I've opened a PR with a fix - #142

  Message: 
System.InvalidOperationException : Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.

  Stack Trace: 
Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
Dictionary`2.set_Item(TKey key, TValue value)
JsonMapper.RegisterExporter[T](ExporterFunc`1 exporter) line 922
JsonSegmentMarshaller.ctor() line 48
UdpSegmentEmitter.ctor() line 45
AWSXRayRecorder.ctor() line 47
TelemetryRecorderTests.ctor() line 25
RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions