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

[Android][Regression] * Assertion at /__w/1/s/src/mono/mono/metadata/object.c:657, condition `lock->done' not met #96804

Closed
mfeingol opened this issue Jan 10, 2024 · 29 comments

Comments

@mfeingol
Copy link

mfeingol commented Jan 10, 2024

Description

After picking up the latest VS update with what I believe is MAUI 8.0.6 SR1, I started seeing the following crash in my app on startup:

  • Assertion at /__w/1/s/src/mono/mono/metadata/object.c:657, condition `lock->done' not met

After some binary searching, I tracked it down to a regression in the 8.0.6-nightly.9806 build. 8.0.6-nightly.9804 works fine.

Steps to Reproduce

Unclear. Possibly do some networking on startup? It's pretty deterministic using my app.

Link to public reproduction project repository

N/A

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.3

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Revert from the SR1 release to the 9804 nightly.

Relevant log output

Not super helpful, but...

Time	Device Name	Type	PID	Tag	Message
	pixel_7_pro_-_api_33	Error	30391	DEBUG	backtrace:
      #00 pc 000000000005f6ff  /apex/com.android.runtime/lib64/bionic/libc.so (abort+191) (BuildId: 007cb2313464df63debf8020e631c990)
      dotnet/maui#1 pc 00000000000277b5  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonodroid.so (xamarin::android::Helpers::abort_application()+5) (BuildId: d72a40c8a47a810bfa98923a8465b70e81cb7e91)
      dotnet/maui#2 pc 00000000000472d9  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::mono_log_handler(char const*, char const*, char const*, int, void*)+105) (BuildId: d72a40c8a47a810bfa98923a8465b70e81cb7e91)
      dotnet/maui#3 pc 000000000021f85a  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#4 pc 000000000021f9e4  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#5 pc 000000000021fa26  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#6 pc 00000000002a9a93  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_class_init_full+2483) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#7 pc 0000000000204c57  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#8 pc 00000000001e773c  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#9 pc 00000000001d9575  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#10 pc 00000000001d6ad1  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#11 pc 00000000000e58ef  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#12 pc 00000000002a8f17  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_invoke_checked+135) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#13 pc 00000000002b1834  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#14 pc 000000000026d024  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#15 pc 000000000027693a  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#16 pc 00000000001e93c8  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#17 pc 00000000001e7df6  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#18 pc 00000000001d91a4  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#19 pc 00000000001d6ad1  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#20 pc 00000000000e58ef  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#21 pc 00000000002a8f17  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_invoke_checked+135) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#22 pc 00000000002b1834  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#23 pc 000000000026d024  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#24 pc 000000000027693a  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#25 pc 00000000001e93c8  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#26 pc 00000000001e7df6  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#27 pc 00000000001d91a4  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#28 pc 00000000001d6ad1  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#29 pc 00000000000e58ef  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#30 pc 00000000002a8f17  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_invoke_checked+135) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      #31 pc 00000000002c0753  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#32 pc 00000000000ccd2a  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+58) (BuildId: 007cb2313464df63debf8020e631c990)
      #33 pc 0000000000060d37  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+55) (BuildId: 007cb2313464df63debf8020e631c990)
@DosangGu
Copy link

Same issue here. Got this issue after updated my visual studio 2022 to 17.8.4.

@DosangGu
Copy link

It doesn't appeared when I launched app with 'Start without Debugging". Seems it has problems with debugger.

@ghost
Copy link

ghost commented Jan 10, 2024

Hi @mfeingol. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@PureWeen
Copy link
Member

@DosangGu do you have a repro you can attach?

@mattleibow
Copy link
Member

@mfeingol does 9806 work again if you don't use debugging?

This is the diff between the nightlies, 1 commit of test, non-shipping code: dotnet/maui@3944004...61ca414

If you try an older and newer nightly, do you get the same results?

@ghost
Copy link

ghost commented Jan 10, 2024

Hi @mfeingol. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@PureWeen PureWeen transferred this issue from dotnet/maui Jan 10, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 10, 2024
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 10, 2024
@mfeingol
Copy link
Author

@mattleibow - I can confirm the issue seems to appear only when the debugger is attached.

These are my experiment results from yesterday:

9802 - good
9804 - good
9806 - bad
9811 - bad
9827 - bad
default version with latest VS / SR1 - bad

@PureWeen - the only repro I can offer at the moment is access to my app on GitHub.

@InquisitorJax
Copy link

InquisitorJax commented Jan 11, 2024

experiencing something similar - app crashes on startup while doing connectivity checks and only when debugger is attached.
If I remove the connectivity checks using the android connectivity manager, then it seems to work ok.
happens on both windows and mac machine with latest VS installs on both

here's a screen grab from the logcat
image

not sure why permission violation for wifi service is triggered - all the correct android permissions are setup.

@ghost
Copy link

ghost commented Jan 11, 2024

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

Issue Details

Description

After picking up the latest VS update with what I believe is MAUI 8.0.6 SR1, I started seeing the following crash in my app on startup:

  • Assertion at /__w/1/s/src/mono/mono/metadata/object.c:657, condition `lock->done' not met

After some binary searching, I tracked it down to a regression in the 8.0.6-nightly.9806 build. 8.0.6-nightly.9804 works fine.

Steps to Reproduce

Unclear. Possibly do some networking on startup? It's pretty deterministic using my app.

Link to public reproduction project repository

N/A

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.3

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Revert from the SR1 release to the 9804 nightly.

Relevant log output

Not super helpful, but...

Time	Device Name	Type	PID	Tag	Message
	pixel_7_pro_-_api_33	Error	30391	DEBUG	backtrace:
      #00 pc 000000000005f6ff  /apex/com.android.runtime/lib64/bionic/libc.so (abort+191) (BuildId: 007cb2313464df63debf8020e631c990)
      dotnet/maui#1 pc 00000000000277b5  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonodroid.so (xamarin::android::Helpers::abort_application()+5) (BuildId: d72a40c8a47a810bfa98923a8465b70e81cb7e91)
      dotnet/maui#2 pc 00000000000472d9  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::mono_log_handler(char const*, char const*, char const*, int, void*)+105) (BuildId: d72a40c8a47a810bfa98923a8465b70e81cb7e91)
      dotnet/maui#3 pc 000000000021f85a  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#4 pc 000000000021f9e4  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#5 pc 000000000021fa26  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#6 pc 00000000002a9a93  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_class_init_full+2483) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#7 pc 0000000000204c57  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#8 pc 00000000001e773c  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#9 pc 00000000001d9575  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#10 pc 00000000001d6ad1  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#11 pc 00000000000e58ef  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#12 pc 00000000002a8f17  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_invoke_checked+135) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#13 pc 00000000002b1834  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#14 pc 000000000026d024  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#15 pc 000000000027693a  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#16 pc 00000000001e93c8  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#17 pc 00000000001e7df6  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#18 pc 00000000001d91a4  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#19 pc 00000000001d6ad1  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#20 pc 00000000000e58ef  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#21 pc 00000000002a8f17  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_invoke_checked+135) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#22 pc 00000000002b1834  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#23 pc 000000000026d024  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#24 pc 000000000027693a  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#25 pc 00000000001e93c8  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#26 pc 00000000001e7df6  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#27 pc 00000000001d91a4  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#28 pc 00000000001d6ad1  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#29 pc 00000000000e58ef  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#30 pc 00000000002a8f17  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (mono_runtime_invoke_checked+135) (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      #31 pc 00000000002c0753  /data/app/~~bY6BuUiuB-gII_WXkHTF8Q==/com.Backroads.Android-ytDQ8E3yi_nPsFa8vMS1-Q==/lib/x86_64/libmonosgen-2.0.so (BuildId: 15beacb4f7391331d2f844e5b3ac0cac28355d90)
      dotnet/maui#32 pc 00000000000ccd2a  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+58) (BuildId: 007cb2313464df63debf8020e631c990)
      #33 pc 0000000000060d37  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+55) (BuildId: 007cb2313464df63debf8020e631c990)
Author: mfeingol
Assignees: -
Labels:

os-android, untriaged, needs-area-label

Milestone: -

@steveisok
Copy link
Member

@thaystg can you take a look when you have a moment?

@teo-tsirpanis teo-tsirpanis removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 11, 2024
@thaystg
Copy link
Member

thaystg commented Jan 11, 2024

@mattleibow - I can confirm the issue seems to appear only when the debugger is attached.

These are my experiment results from yesterday:

9802 - good
9804 - good
9806 - bad
9811 - bad
9827 - bad
default version with latest VS / SR1 - bad

@PureWeen - the only repro I can offer at the moment is access to my app on GitHub.

Can you please give me access to your repo?

@mfeingol
Copy link
Author

Can you please give me access to your repo?

@thaystg: I've added you to the Sideroads repo. Clone and checkout the maui branch for the MAUI port of the app. You should be able to F5 on the Sideroads.Maui project and immediately observe the repro.

@akrol95
Copy link

akrol95 commented Jan 12, 2024

I'm facing the same problem.

Installed Workload Id      Manifest Version      Installation Source
--------------------------------------------------------------------
maui-ios                   8.0.3/8.0.100         SDK 8.0.100 
maui-android               8.0.3/8.0.100         SDK 8.0.100        
maui                       8.0.3/8.0.100         SDK 8.0.100      

@Cheesebaron
Copy link

I just helped getting @InquisitorJax's environment working again.

He had SDK 8.0.101 installed and android 34.0.52 workload.

We rolled back the SDK by uninstalling it and having 8.0.100 installed:

sudo rm -r /usr/local/share/dotnet/sdk/8.0.101

Then once this is done we made sure to install workloads from the 8.0.3 manifest:

sudo dotnet workload update --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/8.0.3.json

@InquisitorJax
Copy link

to be clear - it was 34.0.52 that was the main cause - the 8.0.101 install was a failed attempt at fixing the issue. But to get rollback to 34.0.43 to work, it required uninstalling 8.0.101

@akrol95
Copy link

akrol95 commented Jan 12, 2024

To confirm - I also had 34.0.52 of microsoft.net.sdk.android.
After rollback to 34.0.43 it works properly.

@mfeingol
Copy link
Author

@mattleibow: I should add one thing to what I mentioned earlier, which is that I don't think this is only an issue with debug builds in the debugger. I'm seeing the same issue in release builds on physical devices as well - no debugger attached. Debug builds do appear to work.

@lambdageek
Copy link
Member

This is a regression due to #93943 that will be fixed by #96905

@mfeingol
Copy link
Author

Thanks, @lambdageek. Two questions:

  1. Is there an easy way to revert to a previous version without too much surgery?
  2. How will the fix be released? Next update to VS?

lambdageek added a commit that referenced this issue Jan 12, 2024
* mono_runtime_class_init_full: handle spurious wakeups

the condition variable may be signaled even if the initialization by
the other thread is not done yet.  Handle spurious wakeups the same
way as timeouts: go around once more from the beginning.

Fixes #96872 and #96804

* fix unbalanced handle frames

if we goto retry_top, don't set up a new handle frame that lacks a
matching HANDLE_FUNCTION_RETURN_VAL.

Instead setup the handle frame once upfront
lambdageek added a commit that referenced this issue Jan 13, 2024
#96905)

* mono_runtime_class_init_full: handle spurious wakeups

the condition variable may be signaled even if the initialization by
the other thread is not done yet.  Handle spurious wakeups the same
way as timeouts: go around once more from the beginning.

Fixes #96872 and #96804

* fix unbalanced handle frames

if we goto retry_top, don't set up a new handle frame that lacks a
matching HANDLE_FUNCTION_RETURN_VAL.

Instead setup the handle frame once upfront

---------

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
@lambdageek
Copy link
Member

How will the fix be released? Next update to VS?

The fix will be part of the next servicing release of .NET 8. The servicing releases are usually monthly, so the next one will be in February. Usually Visual Studio updates also include .NET SDK updates.

Is there an easy way to revert to a previous version without too much surgery?

I'm not sure. Maybe @mattleibow has some ideas?


the underlying issue happens when two or more threads attempt to run the static constructors for the same class. it may be possible to mitigate or work around the issue by limiting or delaying parallel execution.

Turning on debug logging with adb shell debug.mono.env "'MONO_LOG_LEVEL=debug|MONO_LOG_MASK=type'" (see Xamarin.Android Environment) and then running the app and looking through the adb log output when the crash happens might give you an idea of which static constructor is running. It might be possible to either cause the static constructor to run earlier, or to find some way to only have it run from a single thread.

@lambdageek lambdageek removed the untriaged New issue has not been triaged by the area owner label Jan 13, 2024
@lambdageek lambdageek added this to the 8.0.x milestone Jan 13, 2024
@mfeingol
Copy link
Author

@lambdageek: thanks! I tracked down my particular race condition and have worked around the issue for now.

@ChristopherStephan
Copy link

We were also able to reproduce this error with Android SDK 31, 33 and 34.

@lambdageek
Copy link
Member

We were also able to reproduce this error with Android SDK 31, 33 and 34.

Thanks. Yea, I would expect the issue is not dependent on the version of the Android SDK. The regression is in the .NET runtime that is used when .NET programs are deployed on android devices. It depends on the version of the .NET SDK, not the Android SDK

@lambdageek
Copy link
Member

lambdageek commented Jan 17, 2024

For anyone experiencing this issue, there are two options to unblock yourselves while we wait for the February .NET 8 servicing release:

  1. See [Android][Regression] * Assertion at /__w/1/s/src/mono/mono/metadata/object.c:657, condition `lock->done' not met #96804 (comment)
    Use additional logging to find the static constructor that is likely being initialized in parallel and add some code to force the static constructor to run on a single thread, earlier.

  2. Or, you can add the following to temporarily force the .NET 8.0.101 SDK to use the 8.0.0 runtime pack (obviously this means you miss out on some of the 8.0.1 fixes, but you also miss out on this 8.0.1 regression):

    <Target Name="UpdateRuntimePackVersion" BeforeTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <KnownRuntimePack Condition="%(RuntimePackLabels) == 'Mono'" LatestRuntimeFrameworkVersion="8.0.0" />
      </ItemGroup>
    </Target>

Once the 8.0.200 SDK (8.0.2 runtime) is out, the workaround can be removed.

tmds pushed a commit to tmds/runtime that referenced this issue Jan 23, 2024
* mono_runtime_class_init_full: handle spurious wakeups

the condition variable may be signaled even if the initialization by
the other thread is not done yet.  Handle spurious wakeups the same
way as timeouts: go around once more from the beginning.

Fixes dotnet#96872 and dotnet#96804

* fix unbalanced handle frames

if we goto retry_top, don't set up a new handle frame that lacks a
matching HANDLE_FUNCTION_RETURN_VAL.

Instead setup the handle frame once upfront
@hansmbakker
Copy link

hansmbakker commented Feb 2, 2024

Once the 8.0.200 SDK (8.0.2 runtime) is out, the workaround can be removed.

@lambdageek Visual Studio 17.9 preview ships 8.0.200-preview.23624.5 already - is that one supposed to contain the fix for this or is that a build from before the fix?

If so - then the fix does not cover my case of * Assertion at /__w/1/s/src/mono/mono/metadata/object.c:657, condition 'lock->done' not met.

I have a .NET MAUI app where I have the following code in my custom FormField control - I started getting this bug when I added that propertyChanged handler. Click to expand the code.
public static readonly BindableProperty IsValidProperty = BindableProperty.Create(
    propertyName: nameof(IsValid),
    returnType: typeof(bool),
    declaringType: typeof(FormField),
    defaultValue: true,
    propertyChanged: OnIsValidChanged);

public bool IsValid
{
    get => (bool)this.GetValue(IsValidProperty);
    set => this.SetValue(IsValidProperty, value);
}

private static void OnIsValidChanged(BindableObject bindable, object oldValue, object newValue)
{
    if (bindable is not FormField formField)
    {
        return;
    }

    var newStateIsValid = newValue.Equals(true);
    TrySetIsValidState(formField, newStateIsValid);
}

private static void TrySetIsValidState(FormField formField, bool newStateIsValid)
{
    ArgumentNullException.ThrowIfNull(formField);

    if (formField.GetTemplateChild("rootLayout") is VerticalStackLayout rootLayout)
    {
        VisualStateManager.GoToState(rootLayout, newStateIsValid ? "Valid" : "Invalid");
    }
}

@lambdageek
Copy link
Member

8.0.200-preview.23624.5

@hansmbakker that's the version of the .NET SDK (and it's a preview version - the released version number will be something like 8.0.200 without a preview tag).

What we want is the 8.0.2 version of the android runtime pack

     Directory: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.android-arm64

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           1/19/2024 12:06 PM                7.0.15
d----           1/19/2024 12:06 PM                8.0.1

@hansmbakker
Copy link

Aah, then I misunderstood - I thought it might be bundled somehow. Thank you for clarifying!

@bcaceiro
Copy link

bcaceiro commented Feb 9, 2024

So when will this be available for MAUI?

@lambdageek
Copy link
Member

dotnet sdk 8.0.200 is available now, including the 8.0.2 runtime pack.

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