Repository navigation
Description
Android application type
.NET Android (net7.0-android, net8.0-android, etc.)
Affected platform version
.NET 8
Description
When working with Maui, we encountered a problem. Sometimes, if you hover the mouse over a variable, the application on Android crashes when trying to evaluate a value with error in logcat: condition 'nfields == 0' not met.
Screen.Recording.2024-01-19.at.17.17.56.mp4
Steps to Reproduce
Unfortunately, I can't provide an example to reproduce, as it doesn't reproduce on a simple application.
As I understand it, the problem occurs on this line in the libmono-component-debugger library:
https://github.com/mono/mono/blob/38b0227c1ce0c53058a5d78d080923435132773a/mono/mini/debugger-agent.c#L5630C2-L5630C11
Perhaps you know how to disable assertion for an application (there is some option in the csproj or you can set some variable with the adb shell)?
Did you find any workaround?
Relevant log output
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
01-19 16:38:12.376 20067 20067 F DEBUG : Abort message: '* Assertion at /__w/1/s/src/mono/mono/component/debugger-agent.c:5521, condition `nfields == 0' not met'
01-19 16:38:12.376 20067 20067 F DEBUG : rax 0000000000000000 rbx 00007ffd445a57c8 rcx 0000711b5dd03610 rdx 0000000000000006
01-19 16:38:12.377 20067 20067 F DEBUG : r8 0000000000000000 r9 0000000000000000 r10 00007ffd445a57d0 r11 0000000000000203
01-19 16:38:12.377 20067 20067 F DEBUG : r12 000071191c2fa136 r13 0000000000000000 r14 0000000000004e2c r15 0000000000004e2c
01-19 16:38:12.377 20067 20067 F DEBUG : rdi 0000000000004e2c rsi 0000000000004e2c
01-19 16:38:12.377 20067 20067 F DEBUG : rbp 0000000000000004 rsp 00007ffd445a57c0 rip 0000711b5dd03610
01-19 16:38:12.377 20067 20067 F DEBUG : 16 total frames
01-19 16:38:12.377 20067 20067 F DEBUG : backtrace:
01-19 16:38:12.377 20067 20067 F DEBUG : #00 pc 0000000000061610 /apex/com.android.runtime/lib64/bionic/libc.so (abort+192) (BuildId: fa337969c798946280caa45e2d71a2e7)
01-19 16:38:12.377 20067 20067 F DEBUG : #01 pc 00000000000334ab /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #02 pc 000000000003323a /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #03 pc 00000000000333c4 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #04 pc 0000000000033406 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #05 pc 0000000000027a24 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #06 pc 0000000000019a4d /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #07 pc 000000000002796e /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #08 pc 0000000000019a4d /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #09 pc 00000000000187b2 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #10 pc 0000000000015961 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #11 pc 0000000000018005 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #12 pc 000000000001784f /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #13 pc 000000000002c6c7 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #14 pc 0000000000023685 /data/app/~~MUkR16U5S80Q4lyx5vlMKQ==/com.Maui.Controls.Tests-JXpS9RnRnPX8B8uFbokXRw==/lib/x86_64/libmono-component-debugger.so (BuildId: 1c74febae626d008490d4a981f019b38025930af)
01-19 16:38:12.377 20067 20067 F DEBUG : #15 pc 000000000000007e <anonymous:41f0e000>
Activity
lambdageek commentedon Jan 22, 2024
@thaystg
grendello commentedon Jan 22, 2024
@thaystg would you be able to look at this issue? Thanks!
thaystg commentedon Jan 22, 2024
Hi, @JaneySprings are you using Hot Reload to change your code and applying changes while debugging, or only debugging?
JaneySprings commentedon Jan 22, 2024
Hi, @thaystg ! Its debugging only.
I understand that this is difficult, since I'm not giving you any example. Do you know if there is any way to disable these
g_assert? It will be enough.thaystg commentedon Jan 22, 2024
Unfortunately, no way to disable it.
Also I would like to fix it in our side.
thaystg commentedon Jan 22, 2024
Which version of VS are you using?
JaneySprings commentedon Jan 22, 2024
I'm using latest VSCode with .NET Meteor extension
It uses this commit of the
debugger-libsrepository (I also test it on the HEAD of repo).You can check the debugger implementation but it's very simple.
I think
MAUI Extension for VSCodewill have the same problem, since the error is on thelibmono-component-debuggerside.thaystg commentedon Jan 22, 2024
As you are able to replace debugger-libs, can you please tell me what expression it's trying to evaluate when you have this assertion, this may help me. To know what expression you are trying to evaluate you can try to add a log here:
https://github.com/mono/debugger-libs/blob/6e097cede7977b67fe81538aac8e718df6db3a89/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs#L155
In all these methods:
InvokeMethod,BeginInvokeMethod,InvokeMethodAsync.Something like this, maybe logging to a file.
JaneySprings commentedon Jan 23, 2024
Of course!
I added logging to the
InvokeMethod,BeginInvokeMethod,InvokeMethodAsyncmethods.I forgot to say that the variable leading to the error is:
After the error, I received this information:
In my VS Code extension, there is an option to configure the debugger. I have disabled this option:

For a second, I saw the size of the collection when hovering (Count = 6), but the same error occurred, but with a different log:
I hope this helps!
Thanks, @thaystg
thaystg commentedon Jan 23, 2024
Thanks a lot!!!
@JaneySprings can you please add another log to me? Please do not remove these ones but add this one also:
https://github.com/mono/debugger-libs/blob/84c5c67f3eb96749012491088d7970a57459e805/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs#L742
Console.WriteLine(((StructMirror)v).Type.FullName + "-" + ((StructMirror)v).Fields.Length)Then we will be able to see all the valuetypes that are sent to call this method and maybe we can understand which is with wrong number of fields.
JaneySprings commentedon Jan 23, 2024
Yep, no problem @thaystg !
With
AllowToString:Without
AllowToStringJaneySprings commentedon Jan 23, 2024
I also test it on
iOS. It is also crashes, but the error looks different. Maybe it will be helpful (debugger-libs log information is the same as for Android):thaystg commentedon Jan 24, 2024
Thanks for all the information, I think I found the problem and fixed it :)
thaystg commentedon Jan 24, 2024
Ah, maybe we can be sure that this is the case, can you please add a Console.WriteLine here, to check if it's passing there:
https://github.com/mono/debugger-libs/blob/6e097cede7977b67fe81538aac8e718df6db3a89/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs#L1226
If it's passing there, I probably fixed the problem.
JaneySprings commentedon Jan 24, 2024
Yep,
With
AllowToString:Without
AllowToString:thaystg commentedon Jan 24, 2024
Thanks a lot for all the information. I was able to reproduce it and fix.