0

Description

I am getting a crash from mono, from the logo I dont get anything specific which I can change in the code

[] * Assertion at /Users/builder/jenkins/workspace/archive-mono/2019-06/android/release/mono/metadata/sgen-tarjan-bridge.c:1140, condition `xref_count == xref_index' not met, function:processing_build_callback_data, xref_count is 47 but we added 45 xrefs
[libc] Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 26216 (Thread Pool Wor), pid 25949 (ileapp_colorpoc)

Not sure what is the root cause because same code works fine for 2 iterations. I wrapped everything in try catch to see if there is some exception that I can catch. It seems to be issue with Garbage collector

More log

11-19 09:28:26.586 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 0
11-19 09:28:26.710 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 1
Thread finished: <Thread Pool> #50
The thread 0x32 has exited with code 0 (0x0).
Thread finished: <Thread Pool> #8
The thread 0x8 has exited with code 0 (0x0).
11-19 09:28:45.387 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 0
11-19 09:28:45.506 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 1
11-19 09:28:46.147 D/Mono    ( 2812): GC_BRIDGE waiting for bridge processing to finish
11-19 09:28:46.197 I/zygote64( 2812): Explicit concurrent copying GC freed 914(91KB) AllocSpace objects, 0(0B) LOS objects, 60% free, 3MB/9MB, paused 188us total 25.829ms
11-19 09:28:46.197 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 70 objects 70 opaque 0 ABCs 70 ABCs-bridged 70 ABCs-visible 70 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.11ms tarjan 0.02ms scc-setup 0.02ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.05ms
11-19 09:28:46.197 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 26.93ms
11-19 09:28:46.197 D/Mono    ( 2812): GC_MINOR: (Nursery full) time 4.43ms, stw 36.62ms promoted 312K major size: 22960K in use: 21279K los size: 33520K in use: 30683K
Thread started: <Thread Pool> #66
Thread started: <Thread Pool> #67
Thread started: <Thread Pool> #68
Thread started: <Thread Pool> #69
Thread started: <Thread Pool> #70
Thread started: <Thread Pool> #71
Thread started: <Thread Pool> #72
Thread started: <Thread Pool> #73
Thread started: <Thread Pool> #74
Thread started: <Thread Pool> #75
11-19 09:28:47.362 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 0 objects 0 opaque 0 ABCs 0 ABCs-bridged 0 ABCs-visible 70 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.11ms tarjan 0.02ms scc-setup 0.02ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.00ms
11-19 09:28:47.362 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 0.12ms
11-19 09:28:47.362 D/Mono    ( 2812): GC_MINOR: (Nursery full) time 6.18ms, stw 8.96ms promoted 1072K major size: 24048K in use: 22372K los size: 33520K in use: 30898K
11-19 09:28:47.420 I/Choreographer( 2812): Skipped 114 frames!  The application may be doing too much work on its main thread.
11-19 09:28:47.439 D/InputMethodManager( 2812): HSIFW - flag : 0 Pid : 2812
[0:] no non-static method "Landroid/support/v7/widget/AppCompatButton;.setOutlineAmbientShadowABC(I)V": Cannot set property on attached control. Error: 
11-19 09:28:47.977 I/zygote64( 2812): Explicit concurrent copying GC freed 1730(279KB) AllocSpace objects, 0(0B) LOS objects, 59% free, 4MB/10MB, paused 192us total 24.513ms
11-19 09:28:47.982 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 54 objects 124683 opaque 79915 ABCs 54 ABCs-bridged 54 ABCs-visible 54 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.06ms tarjan 37.60ms scc-setup 0.05ms gather-xref 0.00ms xref-setup 0.00ms cleanup 3.79ms
11-19 09:28:47.982 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 29.27ms
11-19 09:28:47.982 D/Mono    ( 2812): GC_MINOR: (Nursery full) time 50.29ms, stw 53.89ms promoted 1007K major size: 25104K in use: 23388K los size: 33520K in use: 31980K
11-19 09:28:49.369 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 0
11-19 09:28:49.436 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 1
11-19 09:28:49.473 I/zygote64( 2812): Do full code cache collection, code=1006KB, data=654KB
11-19 09:28:49.478 I/zygote64( 2812): After code cache collection, code=993KB, data=595KB
11-19 09:28:50.120 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 0
11-19 09:28:50.229 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 1
Thread finished: <Thread Pool> #53
The thread 0x35 has exited with code 0 (0x0).
Thread finished: <Thread Pool> #24
The thread 0x18 has exited with code 0 (0x0).
11-19 09:29:00.327 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 0
11-19 09:29:00.421 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 1
11-19 09:29:00.536 D/Mono    ( 2812): GC_BRIDGE waiting for bridge processing to finish
11-19 09:29:00.562 I/zygote64( 2812): Explicit concurrent copying GC freed 921(62KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4MB/10MB, paused 198us total 25.136ms
11-19 09:29:00.569 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 172 objects 128603 opaque 81203 ABCs 172 ABCs-bridged 172 ABCs-visible 172 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.04ms tarjan 36.83ms scc-setup 1.53ms gather-xref 0.00ms xref-setup 0.00ms cleanup 5.67ms
11-19 09:29:00.569 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 34.23ms
11-19 09:29:00.569 D/Mono    ( 2812): GC_MINOR: (Concurrent start) time 49.75ms, stw 91.64ms promoted 1186K major size: 26320K in use: 24598K los size: 36360K in use: 35129K
11-19 09:29:00.569 D/Mono    ( 2812): GC_MAJOR_CONCURRENT_START: (Minor allowance)
Thread started: <Thread Pool> #76
Thread started: <Thread Pool> #77
Thread started: <Thread Pool> #78
Thread started: <Thread Pool> #79
Thread started: <Thread Pool> #80
Thread started: <Thread Pool> #81
Thread started: <Thread Pool> #82
Thread started: <Thread Pool> #83
Thread started: <Thread Pool> #84
Thread started: <Thread Pool> #85
Thread started: <Thread Pool> #86
Thread started: <Thread Pool> #87
Thread started: <Thread Pool> #88
Thread started: <Thread Pool> #89
Thread started: <Thread Pool> #90
Thread started: <Thread Pool> #91
Thread started: <Thread Pool> #92
Thread started: <Thread Pool> #93
Thread started: <Thread Pool> #94
Thread started: <Thread Pool> #95
11-19 09:29:01.699 I/zygote64( 2812): Explicit concurrent copying GC freed 2884(555KB) AllocSpace objects, 0(0B) LOS objects, 59% free, 4MB/10MB, paused 373us total 24.236ms
11-19 09:29:01.702 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 760 objects 5665 opaque 1666 ABCs 758 ABCs-bridged 716 ABCs-visible 716 xref 55 cache-hit 0 cache-semihit 0 cache-miss 42 setup 0.05ms tarjan 2.06ms scc-setup 0.16ms gather-xref 0.03ms xref-setup 0.04ms cleanup 0.42ms
11-19 09:29:01.702 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 31.90ms
11-19 09:29:01.702 D/Mono    ( 2812): GC_MAJOR_CONCURRENT_FINISH: (finishing) time 1174.60ms, stw 21.14ms los size: 25000K in use: 20597K
11-19 09:29:01.702 D/Mono    ( 2812): GC_MAJOR_SWEEP: major size: 22976K in use: 18662K
11-19 09:29:02.862 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 0 objects 0 opaque 0 ABCs 0 ABCs-bridged 0 ABCs-visible 716 xref 55 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.05ms tarjan 2.06ms scc-setup 0.16ms gather-xref 0.03ms xref-setup 0.04ms cleanup 0.00ms
11-19 09:29:02.863 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 0.12ms
11-19 09:29:02.863 D/Mono    ( 2812): GC_MINOR: (Nursery full) time 10.50ms, stw 411.05ms promoted 847K major size: 23104K in use: 19526K los size: 27840K in use: 23530K
11-19 09:29:03.049 D/Mono    ( 2812): GC_TAR_BRIDGE bridges 0 objects 0 opaque 0 ABCs 0 ABCs-bridged 0 ABCs-visible 716 xref 55 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.05ms tarjan 2.06ms scc-setup 0.16ms gather-xref 0.03ms xref-setup 0.04ms cleanup 0.00ms
11-19 09:29:03.049 D/Mono    ( 2812): GC_BRIDGE: Complete, was running for 0.08ms
11-19 09:29:03.049 D/Mono    ( 2812): GC_MINOR: (Nursery full) time 10.30ms, stw 124.74ms promoted 1100K major size: 23104K in use: 20627K los size: 27840K in use: 24615K
11-19 09:29:03.056 I/Choreographer( 2812): Skipped 157 frames!  The application may be doing too much work on its main thread.
11-19 09:29:03.074 D/InputMethodManager( 2812): HSIFW - flag : 0 Pid : 2812
[0:] no non-static method "Landroid/support/v7/widget/AppCompatButton;.setOutlineAmbientShadowABC(I)V": Cannot set property on attached control. Error: 
11-19 09:29:03.751 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 0
11-19 09:29:03.767 W/zygote64( 2812): Checksum mismatch for dex base.apk
11-19 09:29:03.767 W/zygote64( 2812): Checksum mismatch for dex base.apk
11-19 09:29:03.810 D/ViewRootImpl@5d456e4[MainActivity]( 2812): ViewPostIme pointer 1
11-19 09:29:03.940 F/        ( 2812): * Assertion at /Users/builder/jenkins/workspace/archive-mono/2019-06/android/release/mono/metadata/sgen-tarjan-bridge.c:1140, condition `xref_count == xref_index' not met, function:processing_build_callback_data, xref_count is 61 but we added 59 xrefs
11-19 09:29:03.941 F/libc    ( 2812): Fatal signal 6 (SIGABRT), code -6 in tid 2943 (Thread Pool Wor)


Code

    System.Collections.Concurrent.ConcurrentStack<MyClass1> myobjs = new System.Collections.Concurrent.ConcurrentStack<MyClass1>();

    System.Threading.Tasks.Parallel.ForEach(viewModel.Searchobjs, (item) =>
    {
        if (item.objID != obj.objID)
        {

                myobjs.Push(new MyClass1(item, diff.Diff));

        }
    });
    if (myobjs.Count > 0)
    {
        
            List<MyClass1> closeobjs = myobjs.OrderBy(x => x.Diff).ToList();
            foreach (var item in closeobjs)
            {
                if (!objs.ContainsKey(item.objID))
                {
                    objs.Add(item.objID, item);
                    break;
                }
            }
    
        
    }

I noticed this might have caused by using ParallelTask which might be consuming more memory and creating more garbage to be freed.

Also I am using a Dictionary in the same arena of code

Related issue

Steps to Reproduce

Not exactly sure

Expected Behavior

Should not crash from mono

Actual Behavior

Crashing

I have raised issue at Xamarin.Forms/Github as well. If anyone has encountered this issue and resolved it please help.

Relevant : https://github.com/mono/mono/issues/9314

Community
  • 1
  • 1
Morse
  • 8,258
  • 7
  • 39
  • 64
  • The issue that sticks out to me from your log is "Xamarin.Forms.Button is not compatible with element target type Xamarin.Forms.Label". This link describes that issue in detail: https://github.com/xamarin/Xamarin.Forms/issues/6907 ; And, this link looks like it has a solution: https://stackoverflow.com/questions/57083760/xamarin-forms-styles-support-multiple-target-types – Robert Bruce Nov 15 '19 at 23:18
  • @RobertBruce I have changed all such style issues by defining separate styles for Label and Button. Still I see the issue. I will post the updated log tomorrow. – Morse Nov 17 '19 at 17:37
  • @RobertBruce it only happens on Android, they have made it to be warning instead of throwing exception. Besides this crash does not happen every time the view loads , after few loads it happens. Actual error is `[libc] Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 26216 (Thread Pool Wor), pid 25949 (ileapp_abcpoc` – Morse Nov 19 '19 at 13:38
  • Two things that could help, 1. Place an "Exception catchpoint" through the breakpoints tab and see where the exception is caught. 2. Step through you code and find the exact place and time that your app actually crashes. You can even add more `Console.WriteLine("HERE A");` to help you with this. It's probably not an error with Xamarin Forms or Xamarin. – Saamer Nov 19 '19 at 17:59
  • @Saamer already tried those. never hits except block and place of code is somewhere in paralleltask. It has to do something with GC – Morse Nov 19 '19 at 19:14
  • Thats surprising that it doesnt hit any Console WriteLine statements? If you are sure it's a GC issue, why dont you try the GC functions? https://stackoverflow.com/questions/6005865/prevent-net-garbage-collection-for-short-period-of-time – Saamer Nov 19 '19 at 19:31
  • its not that easy @saamer. the link you suggested has pausing the GC. on other hand we want best GC which is tarjan and its still crashing , I am trying options in https://learn.microsoft.com/en-us/xamarin/android/internals/garbage-collection to set it to `new` and increase heap size now ; as suggested by Xamarin team on github – Morse Nov 19 '19 at 19:35

1 Answers1

0

If anyone is facing the same issue, the solution it to switch the type of debugger from Tarjan to New

  • Create a file Environment.txt and set the properties Build Action as AndroidEnvironment

  • Content will be

MONO_GC_PARAMS=bridge-implementation=new,nursery-size=128‌​m,soft-heap-limit=51‌​2m
  • Make sure your android project .csproj has line like
  <ItemGroup>
    <AndroidEnvironment Include="Environment.txt" />
  </ItemGroup>

Note I had to extend soft-heap-limit since the default was low for my app

  • Run the app
Morse
  • 8,258
  • 7
  • 39
  • 64