-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
iOS app crashes when calling GetValue on Virtual Property #110995
Comments
This issue was moved to xamarin/xamarin-macios#21845 |
With the following changes to the test repo: diff --git a/BindingCrash.iOS/BindingCrash.iOS.csproj b/BindingCrash.iOS/BindingCrash.iOS.csproj
index 1b4b608..f325a78 100644
--- a/BindingCrash.iOS/BindingCrash.iOS.csproj
+++ b/BindingCrash.iOS/BindingCrash.iOS.csproj
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net8.0-ios</TargetFramework>
- <SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
+ <TargetFramework>net9.0-ios</TargetFramework>^M
+ <SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>^M
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
@@ -30,7 +30,7 @@
<UseNativeHttpHandler>True</UseNativeHttpHandler>
<MtouchFloat32>False</MtouchFloat32>
<MtouchI18n>west</MtouchI18n>
- <MtouchNoSymbolStrip>False</MtouchNoSymbolStrip>
+ <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>^M
<MtouchExtraArgs>--force-thread-check --optimize=force-rejected-types-removal --warn-on-type-ref=UIKit.UIWebView -warnaserror:1503</MtouchExtraArgs>
<MtouchInterpreter>-all</MtouchInterpreter>
</PropertyGroup>
diff --git a/BindingCrash.iOS/Info.plist b/BindingCrash.iOS/Info.plist
index c775d76..ffb20b8 100644
--- a/BindingCrash.iOS/Info.plist
+++ b/BindingCrash.iOS/Info.plist
@@ -5,7 +5,7 @@
<key>CFBundleDisplayName</key>
<string>BindingCrash</string>
<key>CFBundleIdentifier</key>
- <string></string>
+ <string>BindingCrash</string>^M
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key> then building and running like this:
I get this stack trace from the crash:
Which looks like an issue with the interpreter. |
@BrzVlad could you please take a look? |
@vitek-karas Hi, I am wondering whether this would be something that would be included in a 8.0.X service release? |
@MDThomsen - we'll look into backporting this once we have the fix merged into main (.NET 10). |
@vitek-karas That's great to hear as this has quite big implications for what I'm developing. |
@MDThomsen - no promises - the fix is relatively large and thus risky :-) Also our first target will be .NET 9. |
@vitek-karas Of course, I completely understand that based on the changes in the PR. I just want to stress that this is quite a breaking bug, and at the moment bumping to .net9 is not an option for the product my team is developing, due to stability issues on .net 9. |
@BrzVlad please try to backport this to both 9 and 8 - we'll see if it meets the bar. |
Reopening as the issues was filed against .NET 8 - we will consider backporting this into 9 and 8. |
@vitek-karas Thank you very much! |
I am working with a maui app that in some instances relies on getting values through reflection.
There is a specific case where a base class has a virtual property, which is then overridden in a parent class.
In the reproduction project there is a base page with:
public virtual bool IsVisible => true;
and then a page that inherits from that base page, which then overrides the property as such:
public override bool IsVisible => true;
When creating an instance of PropertyInfo on the overriden property with
var visibleBindingPropertyInfo = GetType().GetTypeInfo().GetRuntimeProperty(nameof(IsVisible));
and then calling
GetValue
byif (visibleBindingPropertyInfo != null) isVisible = (bool)visibleBindingPropertyInfo.GetValue(this);
causes the iOS app to crash.
The crash occurs when the interpreter is disabled like so;
<MtouchInterpreter>-all</MtouchInterpreter>
If the Interpreter is enabled, then it will not crash. However using the Interpreter is not an option in my case, as it downgrades the performance too much for a production build.
The crash started occurring after updating to VS 2022 with the following workload list:
However on the previous installation of visual studio with the following workload list, it is working without crashing:
I also noticed this ticket #96611 which mentions something similar, however that is older than the release of 8.0.40 in which it was working.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/MDThomsen/BindingCrash.git
Version with bug
8.0.82 SR8.2
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.40 SR5
Affected platforms
iOS
Affected platform versions
18.0.8303/8.0.100
Did you find any workaround?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: