-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Possible thread-unsafe serialization - DefaultReferenceResolver #1452
Comments
#1393 should fix this issue. If that's not accepted |
@JamesNK Please consider fixing this concurrency issue. I've laid out the potential fixes, just waiting on you to okay a direction. |
@TylerBrinkley @JamesNK My app is hitting this issue during heavy usage in production :( |
It's actual for v.11 |
@JamesNK Please consider fixing this concurrency issue. I've laid out the potential fixes, just waiting on you to okay a direction. |
Me thought ReferanceResolver was the cause of wierd output but turned out to be static variable elsewhere.. |
I use |
Had a similar issue (but it's hard to reproduce) with
|
Why has this not been fixed yet? I'm hitting this issue in 12.0.3. I really can't understand why this issue has been sitting unfixed for 3 YEARS. |
One year on and still not fixed. |
This is normal for oss. |
This is still a major problem. Why has this not been fixed? Especially when the fix is so drop dead simple? I see version after version after version released for this software, and that's great. But why such a simple fix keeps getting ignored is beyond my understanding. |
This is normal for oss project which is no longer actively developed. |
Looks like it is actively being developed to me. And, the issue has been open for 5 years now. |
https:/JamesNK/Newtonsoft.Json/graphs/contributors Over the past few years, trends (commits, open/merged PRs) are obvious. |
I did write something on an issue around here somewhere a few year ago. Anyways my issue was actually poor thread safety else were that made Newtonsoft go boom. Check for static variables elsewhere, that could be a clue for some. I believed it had something to do with extensive caching of Newtonsoft that made it appear like an error from here. |
Application I am developing has been throwing for some time intermittent exceptions:
I tried reproducing in debug sessions, but I couldn't get any results. After that, I started looking at the code based on the stack trace, which lead to method https:/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs#L366. From there, I went to https:/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Serialization/DefaultReferenceResolver.cs#L69. I suspect that JsonSerializer is not thread-safe because of this resolver. Although JsonSerializerInternalWriter is instantiated for each serialization/deserialization process (therefore the reference mappings are also "local"), the resolver is provided by JsonSerializer via method https:/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/JsonSerializer.cs#L1150, which means that the resolver is reused between different threads (which could be parallel). Since the _referenceCount field is reused, any access to it should be locked, as two parallel threads might start incrementing and using the same value for reference. Can you please confirm my suspicions and maybe fix this in next release? Thank you!
Steps to reproduce
Highly unlikely to reproduce, as the referenceCount incrementation must occur at almost the same time on two parallel threads.
The text was updated successfully, but these errors were encountered: