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

[mono][ios] ToFrozenSet crashes on iOS devices with 8.0.3 release #101427

Closed
ivanpovazan opened this issue Apr 23, 2024 · 5 comments
Closed

[mono][ios] ToFrozenSet crashes on iOS devices with 8.0.3 release #101427

ivanpovazan opened this issue Apr 23, 2024 · 5 comments
Assignees
Milestone

Comments

@ivanpovazan
Copy link
Member

ivanpovazan commented Apr 23, 2024

Description

With 8.0.3+ servicing release if an iOS app uses ToFrozenSet directly (or through some dependency CommunityToolkit) the app crashes with something like:

at System.Collections.Frozen.SmallFrozenSet`1.GSW[[UIKit.UIView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].Store(FrozenSet`1 )
   at System.Collections.Frozen.FrozenSetInternalBase`2[[UIKit.UIView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065],[System.Collections.Frozen.SmallFrozenSet`1.GSW[[UIKit.UIView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]], System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]..ctor(IEqualityComparer`1 )
   at System.Collections.Frozen.SmallFrozenSet`1[[UIKit.UIView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]]..ctor(HashSet`1 )
   at System.Collections.Frozen.FrozenSet.CreateFromSet[UIView](HashSet`1 )
   at System.Collections.Frozen.FrozenSet.ToFrozenSet[UIView](IEnumerable`1 , IEqualityComparer`1 )
   at CommunityToolkit.Maui.Core.Views.AlertView.get_Children()
   at CommunityToolkit.Maui.Core.Views.AlertView.Initialize()
   at CommunityToolkit.Maui.Core.Views.Alert.Show()
   at CommunityToolkit.Maui.Alerts.Toast.ShowPlatform(CancellationToken token)
   at CommunityToolkit.Maui.Alerts.Toast.Show(CancellationToken token)
   at KinesiaOne.ViewModels.SettingsPageViewModel.VersionTapped()

Regression

Yes, this is a regression compared to 8.0.2 servicing release, and is caused by this backport: #97850

Analysis

The problem seems to be related to the fact that the problematic backport actually needs #94787 also to be backported in order to work properly.
@kotlarmilos could you issue the backport?

This is not reproducible on the main (.NET9) branch because we have the both changes (linked above) merged in.

Known workarounds

Reported as issue

Originally reported in various places:
CommunityToolkit/Maui#1752
CommunityToolkit/Maui#1768
MudBlazor/MudBlazor#6558

Copy link
Contributor

Tagging subscribers to 'os-ios': @steveisok, @akoeplinger, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@ivanpovazan
Copy link
Member Author

ivanpovazan commented Apr 23, 2024

Smaller repro with a full AOTed console app (that crashes with 8.0.3 release):

using System;
using System.Collections.Generic;
using System.Collections.Frozen;

namespace HelloWorld
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            try
            {
                var people = new List<Person>()
                { 
                    new Person("John") 
                };

                foreach (var frozenPerson in people.ToFrozenSet())
                {
                    Console.WriteLine($"Element in frozen set has: {frozenPerson.Name} name");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }

    class Person
    {
        public Person(string name) => Name = name;
        public string Name { get; set; }
    }
}

@jkotas
Copy link
Member

jkotas commented Apr 23, 2024

FWIW, CommunityToolkit should not be using FrozenSet in the first place. I have filled CommunityToolkit/Maui#1829 on it.

@plppp2001
Copy link

FWIW, CommunityToolkit should not be using FrozenSet in the first place. I have filled CommunityToolkit/Maui#1829 on it.

Yeah exactly. Agreed.

@lambdageek
Copy link
Member

Fixed in .NET 8.0.7

theofanis added a commit to bol-project/bol-wallet that referenced this issue Jul 24, 2024
.NET 8.0.7 has fixed an issue with the use of ToFrozenSet, more info dotnet/runtime#101427.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants