Skip to content

Abort message: '* Assertion at /__w/1/s/src/mono/mono/component/debugger-agent.c:5521, condition `nfields == 0' not met' #8653

Closed
dotnet/runtime
#97418

Description

@JaneySprings

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

  1. added
    Area: App Runtime
    needs-triage
    on Jan 19, 2024
  2. lambdageek commented on Jan 22, 2024

    @lambdageek
    Member
  3. grendello commented on Jan 22, 2024

    @grendello
    Contributor

    @thaystg would you be able to look at this issue? Thanks!

  4. thaystg commented on Jan 22, 2024

    @thaystg
    Member

    Hi, @JaneySprings are you using Hot Reload to change your code and applying changes while debugging, or only debugging?

  5. JaneySprings commented on Jan 22, 2024

    @JaneySprings
    Author

    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.

  6. thaystg commented on Jan 22, 2024

    @thaystg
    Member

    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.

    Unfortunately, no way to disable it.
    Also I would like to fix it in our side.

  7. thaystg commented on Jan 22, 2024

    @thaystg
    Member

    Which version of VS are you using?

  8. JaneySprings commented on Jan 22, 2024

    @JaneySprings
    Author

    I'm using latest VSCode with .NET Meteor extension

    It uses this commit of the debugger-libs repository (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 VSCode will have the same problem, since the error is on the libmono-component-debugger side.

  9. thaystg commented on Jan 22, 2024

    @thaystg
    Member

    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.

    if (this_obj is StructMirror)
        Console.WriteLine(method.Name + "-" +  ((StructMirror)this_obj).Type.FullName  + "-" + ((StructMirror)this_obj).Fields.Length);
    
  10. JaneySprings commented on Jan 23, 2024

    @JaneySprings
    Author

    Of course!
    I added logging to the InvokeMethod, BeginInvokeMethod, InvokeMethodAsync methods.

    I forgot to say that the variable leading to the error is:

    protected Dictionary<object, Microsoft.Maui.Controls.View> Cache { get; }

    After the error, I received this information:

    BeginInvokeMethod: ToString-System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    

    In my VS Code extension, there is an option to configure the debugger. I have disabled this option:
    image

    For a second, I saw the size of the collection when hovering (Count = 6), but the same error occurred, but with a different log:

    BeginInvokeMethod: get_Key-System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    

    I hope this helps!
    Thanks, @thaystg

  11. thaystg commented on Jan 23, 2024

    @thaystg
    Member

    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.

  12. JaneySprings commented on Jan 23, 2024

    @JaneySprings
    Author

    Yep, no problem @thaystg !

    With AllowToString:

    BeginInvokeMethod: ToString-System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Int32-1
    

    Without AllowToString

    BeginInvokeMethod: get_Key-System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Int32-1
    
  13. JaneySprings commented on Jan 23, 2024

    @JaneySprings
    Author

    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):

    2024-01-23 21:33:26.537540+0400 Maui.Controls.Tests[6262:376111] error: * Assertion at /Users/runner/work/1/s/src/mono/mono/component/debugger-agent.c:2043, condition `id > 0 && GINT_TO_UINT(id) <= ids [type]->len' not met
    
    =================================================================
    Native stacktrace:
    =================================================================
    0x105a30280 - ...app/libmonosgen-2.0.dylib : mono_dump_native_crash_info
    0x1059e02a0 - ...app/libmonosgen-2.0.dylib : mono_handle_native_crash
    0x105d02c08 - ...app/libmonosgen-2.0.dylib : sigabrt_signal_handler.cold.1
    0x105a2fb40 - ...app/libmonosgen-2.0.dylib : mono_runtime_setup_stat_profiler
    0x10316bc60 - /usr/lib/system/libsystem_platform.dylib : _sigtramp
    0x1032db1d0 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
    0x1801605cc - /Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_c.dylib : abort
    0x103341914 - ...app/libmono-component-debugger.dylib : monoeg_log_set_default_handler
    0x103341658 - ...app/libmono-component-debugger.dylib : monoeg_g_logv_nofree
    0x1033416fc - ...app/libmono-component-debugger.dylib : monoeg_assertion_message
    0x103341740 - ...app/libmono-component-debugger.dylib : mono_assertion_message_unreachable
    0x103333cb0 - ...app/libmono-component-debugger.dylib : decode_ptr_id
    0x103334b44 - ...app/libmono-component-debugger.dylib : decode_vtype_compute_size
    0x103327134 - ...app/libmono-component-debugger.dylib : decode_value_compute_size
    0x103334d64 - ...app/libmono-component-debugger.dylib : decode_vtype_compute_size
    0x103327134 - ...app/libmono-component-debugger.dylib : decode_value_compute_size
    0x103325ed8 - ...app/libmono-component-debugger.dylib : mono_do_invoke_method
    0x103323224 - ...app/libmono-component-debugger.dylib : suspend_current
    0x103325760 - ...app/libmono-component-debugger.dylib : process_event
    0x103324f04 - ...app/libmono-component-debugger.dylib : mono_dbg_process_breakpoint_events
    0x103339e38 - ...app/libmono-component-debugger.dylib : mono_de_process_breakpoint
    0x103330548 - ...app/libmono-component-debugger.dylib : debugger_agent_breakpoint_from_context
    0x102be49e4 - ...app/Maui.Controls.Tests : sdb_breakpoint_trampoline
    0x105a3e628 - ...app/libmonosgen-2.0.dylib : do_debugger_tramp
    0x105a3c7b0 - ...app/libmonosgen-2.0.dylib : mono_interp_exec_method
    0x105a310b8 - ...app/libmonosgen-2.0.dylib : interp_entry_from_trampoline
    0x102be9a18 - ...app/Maui.Controls.Tests : native_to_interp_trampoline
    
  14. thaystg commented on Jan 24, 2024

    @thaystg
    Member

    Thanks for all the information, I think I found the problem and fixed it :)

  15. thaystg commented on Jan 24, 2024

    @thaystg
    Member

    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.

  16. JaneySprings commented on Jan 24, 2024

    @JaneySprings
    Author

    Yep,

    With AllowToString:

    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[150] Type:[Object] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[0] Type:[240] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[150] Type:[Object] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[156] Type:[Object] Value:[]
    BeginInvokeMethod: ToString-System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Int32-1
    WriteValue[ValueImpl]: Fields:[Mono.Debugger.Soft.ValueImpl[]] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[117] Objid:[0] Type:[ValueType] Value:[]
    WriteValue[ValueImpl]: Fields:[Mono.Debugger.Soft.ValueImpl[]] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[35] Objid:[0] Type:[ValueType] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[0] Type:[End] Value:[1]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[158] Type:[Object] Value:[]
    

    Without AllowToString:

    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[150] Type:[Object] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[0] Type:[240] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[150] Type:[Object] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[156] Type:[Object] Value:[]
    BeginInvokeMethod: get_Key-System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Collections.Generic.KeyValuePair`2[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Maui.Controls.View, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]-2
    VMEncodeValue: System.Int32-1
    WriteValue[ValueImpl]: Fields:[Mono.Debugger.Soft.ValueImpl[]] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[117] Objid:[0] Type:[ValueType] Value:[]
    WriteValue[ValueImpl]: Fields:[Mono.Debugger.Soft.ValueImpl[]] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[35] Objid:[0] Type:[ValueType] Value:[]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[0] Type:[End] Value:[1]
    WriteValue[ValueImpl]: Fields:[] FixedSize:[0] Id:[0] Index:[0] InlineArray:[] IsEnum:[False] Klass:[0] Objid:[158] Type:[Object] Value:[]
    
  17. thaystg commented on Jan 24, 2024

    @thaystg
    Member

    Thanks a lot for all the information. I was able to reproduce it and fix.

  18. locked and limited conversation to collaborators on Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App Runtimeneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions