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

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

Closed
udlose opened this issue Jan 23, 2023 · 2 comments
Labels
Milestone

Comments

@udlose
Copy link
Contributor

udlose commented Jan 23, 2023

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)
@udlose
Copy link
Contributor Author

udlose commented Aug 29, 2023

I've updated my PR and restored the formatting of the unchanged code. Please review the PR again. #142

@devlead devlead added this to the 0.19.0 milestone Nov 19, 2023
@devlead devlead added the bug label Nov 19, 2023
@devlead
Copy link
Member

devlead commented Nov 19, 2023

Fixed by #142

@devlead devlead closed this as completed Nov 19, 2023
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

2 participants