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

Fix race condition on static dictionaries #291

Merged
merged 3 commits into from
Jun 11, 2024
Merged

Fix race condition on static dictionaries #291

merged 3 commits into from
Jun 11, 2024

Conversation

udlose
Copy link
Contributor

@udlose udlose commented Aug 29, 2023

*Issue #282 *

Description of changes:

  • fix race condition on static dictionaries, copy recent code from LitJson repo for JsonMapper.cs

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@udlose udlose requested a review from a team as a code owner August 29, 2023 21:49
@jj22ee
Copy link
Contributor

jj22ee commented Sep 1, 2023

Failed TestExceptionStrategy7 [6 ms]
  Error Message:
   Test method Amazon.XRay.Recorder.UnitTests.AwsXrayRecorderBuilderTests.TestExceptionStrategy7 threw exception: 
ThirdParty.LitJson.JsonException: Max allowed object depth reached while trying to export from type System.String
  Stack Trace:
      at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 715

Looks like all failing tests are due to a recursive (infinite?) loop at the WriteValue() method.

ThirdParty.LitJson.JsonException: Max allowed object depth reached while trying to export from type System.String
  Stack Trace:
      at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 715
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 792
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 850
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 850
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 783
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 850
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 850
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 783
   at ThirdParty.LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in /_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:line 850
...

Can you fix the PR, and then we will review the change.

@udlose
Copy link
Contributor Author

udlose commented Sep 2, 2023

@jj22ee my apologies. I had a PITA time trying to get it to build successfully with all of the old dependencies used for backwards compatibility. So, I wasn't able to run any of the tests. I will try to take a look this weekend.

Do you have any tips on making it a little easier to build?

@jj22ee
Copy link
Contributor

jj22ee commented Sep 8, 2023

@udlose are there any specific dependencies you are having trouble with, and what kind of build pains are you running into?

@udlose
Copy link
Contributor Author

udlose commented Sep 13, 2023

@udlose are there any specific dependencies you are having trouble with, and what kind of build pains are you running into?

@jj22ee - the .NET Framework specific dependencies are problematic as I keep only the latest version installed on my laptop. I went and installed .NET Fx 4.62 and .Net Fx 4.51 Multi Targeting Packs. There are multiple references to the compilation symbol NET45 which apparently aren't covered by installing .NET Framework 4.51. I pulled NET45 out of the project dependencies to try and get it to build but there are several references to it in the code for conditional compilation. I don't want to have to do surgery on the code just to get it to compile correctly.

Several of these dependencies are EOL anyways so they really should be removed IMO:

  • NET fx 4.5 (EOL Jan 12, 2016)
  • NET Core 2.1 LTS (EOL Aug 21, 2021)

@jj22ee
Copy link
Contributor

jj22ee commented Jun 11, 2024

@udlose I have pushed a fix into the PR branch:

  1. There was some deleted code in your PR that I restored which does not exist in upstream LitJSON.
  2. Regarding the other synced changes, I removed them as these were incomplete since they did not incorporate the other changes in their respective commits:

To summarize, I've reduced the PR into essentially cherry-picking your upstream PR, alongside incorporating your change into the other existing code change to the copied LitJSON.

@jj22ee jj22ee changed the title - fix race condition on static dictionaries, copy recent code from Li… Fix race condition on static dictionaries Jun 11, 2024
Copy link
Contributor

@jj22ee jj22ee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests now pass, LGTM as it now essentially a cherry-pick of LitJSON/litjson#142. Let me know if you have concerns with my update to your PR.

@jj22ee jj22ee merged commit 62cfacd into aws:master Jun 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants