question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Json serializer fails on iOS in release mode (AOT) - regression in v4.52.0

See original GitHub issue

Stack trace

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_Dictionary`2<string, JToken>_string_JToken (System.Collections.Generic.Dictionary`2<string, Microsoft.Identity.Json.Linq.JToken>,string,Microsoft.Identity.Json.Linq.JToken)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

  ?, in int ActionCallInstruction<Dictionary<string, JToken>, string, JToken>.Run(InterpretedFrame)
  ?, in void Interpreter.Run(InterpretedFrame)
  ?, in object LightLambda.Run(params object[])
  ?, in object DelegateHelpers.FuncThunk2<object, object[], object>(Func<object[], object> handler, object t1, object[] t2)
  ?, in void <>c__DisplayClass45_1.<SetExtensionDataDelegates>b__0(?)+(object o, string key, object value) => { }
  ?, in void JsonSerializerInternalReader.SetExtensionData(JsonObjectContract contract, JsonProperty member, JsonReader reader, string memberName, object o)
Microsoft.Identity.Json.JsonSerializationException: Error setting value in extension data for type 'Microsoft.Identity.Client.OAuth2.MsalTokenResponse'. Path 'not_before', line 1, position 3126.
  ?, in void JsonSerializerInternalReader.SetExtensionData(JsonObjectContract contract, JsonProperty member, JsonReader reader, string memberName, object o)
  ?, in object JsonSerializerInternalReader.PopulateObject(object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, string id)
  ?, in object JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
  ?, in object JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
  ?, in object JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, bool checkAdditionalContent)
  ?, in object JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
  ?, in object JsonConvert.DeserializeObject(string value, Type type, JsonSerializerSettings settings)
  ?, in MsalTokenResponse JsonConvert.DeserializeObject<MsalTokenResponse>(string value, JsonSerializerSettings settings)
  ?, in MsalTokenResponse JsonHelper.DeserializeFromJson<MsalTokenResponse>(string json)
  ?, in MsalTokenResponse OAuth2Client.CreateResponse<MsalTokenResponse>(HttpResponse response, RequestContext requestContext)
  ?, in async void <ExecuteRequestAsync>d__12<MsalTokenResponse>.MoveNext()
  ?, in async Task<MsalTokenResponse> OAuth2Client.GetTokenAsync(Uri endPoint, RequestContext requestContext, bool addCommonHeaders, Func<OnBeforeTokenRequestData, Task> onBeforePostRequestHandler)
  ?, in async Task<MsalTokenResponse> TokenClient.SendHttpAndClearTelemetryAsync(string tokenEndpoint, ILoggerAdapter logger)
  ?, in async Task<MsalTokenResponse> TokenClient.SendTokenRequestAsync(IDictionary<string, string> additionalBodyParameters, string scopeOverride, string tokenEndpointOverride, CancellationToken cancellationToken)
  ?, in async Task<MsalTokenResponse> InteractiveRequest.GetTokenResponseAsync(CancellationToken cancellationToken)
  ?, in async Task<AuthenticationResult> InteractiveRequest.ExecuteAsync(CancellationToken cancellationToken)
  ?, in async Task<AuthenticationResult> RequestBase.RunAsync(CancellationToken cancellationToken)
  ?, in async Task<AuthenticationResult> PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenInteractiveParameters interactiveParameters, CancellationToken cancellationToken)

Which version of MSAL.NET are you using?

Microsoft.Identity.Client 4.52.0 Microsoft.Identity.Client.Extensions.Msal 2.28.0

Platform

MAUI v7.0.59

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Authentication
    • Username Password
    • Device code flow (browserless)
  • Web app
    • Authorization code
    • On-Behalf-Of
  • Daemon app
    • Service to Service calls

Is this a new or existing app?

The app is in production, and I have upgraded to a new version of MSAL.

Possible solution

Fallback to v4.51.0 / v2.27.0

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
espenrlcommented, Apr 14, 2023

Yes, it is a regression in 4.52.0. It works in 4.51.0

0reactions
espenrlcommented, Apr 21, 2023

I think the main problem is return System.Collections.Immutable.ImmutableDictionary<TKey, TValue>.Empty; In my experience AOT doesn’t work well with immutable collections and JSON serialization.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sub-task - Release Notes - Java Bug System
[JDK-8046590] - fix doclint issues in swing classes, part 1 of 4 ... [JDK-8166296] - add documentation for Date,RegExp,Error,JSON objects ...
Read more >
da685abc14ec128bcbd5834ba9...
New upstream release - Run regression tests - Build documentation - Fix BRs ... Version bump to 1.6.4 per bz #1158667 (okay, that...
Read more >
Untitled
4 upstream patches for kernel lockdep hygiene, bz1242368 - rhbz1346112 delay ... exit fullscreen in kiosk mode Resolves: rhbz#1446161 - Do not show...
Read more >
https://googlegroups.com/a/dartlang.org/group/comm...
Bug : https://github.com/dart-lang/sdk/issues/20389 Change-Id: ... in VM This fixes failures of standalone{,_2}/io/platform_test in AOT / AppJIT modes (and ...
Read more >
Untitled
Buy tickets for tonga and new zealand game for tomorrow, Css writing mode, ... Error while opening sound device audacity, Call center jne...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found