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

System.Text.Json.Tests crashing from Debug.Assert in JsonSerializerOptions.GetJsonTypeInfoFromContextOrCreate #66469

Closed
elinor-fung opened this issue Mar 10, 2022 · 5 comments · Fixed by #66522
Assignees
Labels
area-System.Text.Json blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
Milestone

Comments

@elinor-fung
Copy link
Member

elinor-fung commented Mar 10, 2022

From test result and log from #66332 - the example failure was on Linux arm64 on mono, but is being hit on other Unix, x64, and on coreclr as well:

  Starting:    System.Text.Json.Tests (parallel test collections = on, max threads = 6)
Process terminated due to "   at System.Diagnostics.DebugProvider.Fail(String message, String detailMessage) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.cs:line 22
   at System.Diagnostics.Debug.Fail(String message, String detailMessage) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 131
   at System.Diagnostics.Debug.Assert(Boolean condition, String message, String detailMessage) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 95
   at System.Diagnostics.Debug.Assert(Boolean condition) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 80
   at System.Text.Json.JsonSerializerOptions.GetJsonTypeInfoFromContextOrCreate(Type type) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs:line 613
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Text.Json.Serialization.Metadata.JsonTypeInfo, System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]].GetOrAdd(Type key, Func`2 valueFactory) in /_/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs:line 1146
   at System.Text.Json.JsonSerializerOptions.CachingContext.GetOrAddJsonTypeInfo(Type type) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs:line 104
   at System.Text.Json.JsonSerializerOptions.GetOrAddJsonTypeInfo(Type type) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs:line 34
   at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type runtimeType) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs:line 26
   at System.Text.Json.JsonSerializer.DeserializeAsync[SimpleStruct](Stream utf8Json, JsonSerializerOptions options, CancellationToken cancellationToken) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs:line 49
   at System.Text.Json.Serialization.Tests.NullTests.<>c__DisplayClass10_0.<<ParseNullStringShouldThrowJsonExceptionAsync>b__0>d.MoveNext() in /_/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Null.ReadTests.cs:line 193

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Mar 10, 2022
@ghost
Copy link

ghost commented Mar 10, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

Issue Details

From test result and log from #66332 - the failure was on Linux arm64 on mono:

  Starting:    System.Text.Json.Tests (parallel test collections = on, max threads = 6)
Process terminated due to "   at System.Diagnostics.DebugProvider.Fail(String message, String detailMessage) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.cs:line 22
   at System.Diagnostics.Debug.Fail(String message, String detailMessage) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 131
   at System.Diagnostics.Debug.Assert(Boolean condition, String message, String detailMessage) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 95
   at System.Diagnostics.Debug.Assert(Boolean condition) in /_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 80
   at System.Text.Json.JsonSerializerOptions.GetJsonTypeInfoFromContextOrCreate(Type type) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs:line 613
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Text.Json.Serialization.Metadata.JsonTypeInfo, System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]].GetOrAdd(Type key, Func`2 valueFactory) in /_/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs:line 1146
   at System.Text.Json.JsonSerializerOptions.CachingContext.GetOrAddJsonTypeInfo(Type type) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs:line 104
   at System.Text.Json.JsonSerializerOptions.GetOrAddJsonTypeInfo(Type type) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs:line 34
   at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type runtimeType) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs:line 26
   at System.Text.Json.JsonSerializer.DeserializeAsync[SimpleStruct](Stream utf8Json, JsonSerializerOptions options, CancellationToken cancellationToken) in /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs:line 49
   at System.Text.Json.Serialization.Tests.NullTests.<>c__DisplayClass10_0.<<ParseNullStringShouldThrowJsonExceptionAsync>b__0>d.MoveNext() in /_/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Null.ReadTests.cs:line 193

Author: elinor-fung
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@eiriktsarpalis
Copy link
Member

Hmm, we might want to use a volatile write for IsInitializedForReflectionSerializer here:

RootReflectionSerializerDependencies();
IsInitializedForReflectionSerializer = true;

@elinor-fung
Copy link
Member Author

I'm going to mark this as blocking-clean-ci. I've seen this on three different PRs I've been on today.

Query below shows a bunch of hits. Some of them might be a different crash (I don't know how to come up with a query to differentiate), but I opened five of the logs from today and they were all this assert.

WorkItems
| where FriendlyName == "System.Text.Json.Tests"
| where  Queued > ago(3d)
| where ExitCode == 134
| join Jobs on JobId
| project
  Queued,
  FriendlyName, ExitCode, Status,
  ConsoleUri,
  PhaseName = tostring(parse_json(Properties)["System.PhaseName"]),
  Pipeline = tostring(parse_json(Properties).DefinitionName),
  RuntimeFlavor = tostring(parse_json(Properties).runtimeFlavor),
  BuildId = tostring(parse_json(Properties).BuildId),
  QueueName, Source

@elinor-fung elinor-fung added the blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms' label Mar 11, 2022
@eiriktsarpalis
Copy link
Member

I'm OOF but @layomia should be able to take a look at this tomorrow.

@danmoseley
Copy link
Member

As an aside it seems that Debug.Assert(condition) ought to pass a default message.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 11, 2022
@layomia layomia removed untriaged New issue has not been triaged by the area owner in-pr There is an active PR which will close this issue when it is merged labels Mar 11, 2022
@layomia layomia added this to the 7.0.0 milestone Mar 11, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants