question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native skia crash with avalonia.mvvm template targeting net48

See original GitHub issue

Hi all,

I have created a repository to replicate this native crash I am seeing on Mac OS X Catalina when using the basic avalonia mvvm template. This happens when exiting the application… according to the stacktrace looks to be related to finalizer activities / deleting references in Skia. Is this the right place to post…?

=================================================================
    Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

=================================================================
    Native stacktrace:
=================================================================
    0x108272ad9 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : mono_dump_native_crash_info
    0x10820afb5 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : mono_handle_native_crash
    0x10826cc56 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : altstack_handle_and_restore
    0x7fff3fc708ac - /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib : glDeleteBuffers
    0x10fc5f36c - /private/tmp/macosx-avalonia-crash/MyApp/bin/Debug/net48/libSkiaSharp.dylib : gr_backendrendertarget_get_gl_framebufferinfo
    0x10fb03e9f - /private/tmp/macosx-avalonia-crash/MyApp/bin/Debug/net48/libSkiaSharp.dylib : gr_backendrendertarget_get_gl_framebufferinfo
    0x10fb2a9cd - /private/tmp/macosx-avalonia-crash/MyApp/bin/Debug/net48/libSkiaSharp.dylib : gr_backendrendertarget_get_gl_framebufferinfo
    0x10faf104c - /private/tmp/macosx-avalonia-crash/MyApp/bin/Debug/net48/libSkiaSharp.dylib : gr_backendrendertarget_get_gl_framebufferinfo
    0x10fb05615 - /private/tmp/macosx-avalonia-crash/MyApp/bin/Debug/net48/libSkiaSharp.dylib : gr_backendrendertarget_get_gl_framebufferinfo
    0x1102fa5b4 - Unknown
    0x11430d95c - Unknown
    0x1083f3119 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : mono_gc_run_finalize
    0x10841201c - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : sgen_gc_invoke_finalizers
    0x1083f5009 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : finalizer_thread
    0x1083a16ed - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : start_wrapper
    0x7fff6ffc4109 - /usr/lib/system/libsystem_pthread.dylib : _pthread_start
    0x7fff6ffbfb8b - /usr/lib/system/libsystem_pthread.dylib : thread_start

=================================================================
    Telemetry Dumper:
=================================================================
Pkilling 0x11697cdc0 from 0x70000865e000
Entering thread summarizer pause from 0x70000865e000
Finished thread summarizer pause from 0x70000865e000.
Failed to create breadcrumb file (null)/crash_hash_0x8d658a08a

Waiting for dumping threads to resume

=================================================================
    External Debugger Dump:
=================================================================

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x7fff3fc708ac):
0x7fff3fc7089c  89 e5 48 89 f2 89 fe 65 48 8b 04 25 f0 00 00 00  ..H....eH..%....
0x7fff3fc708ac  48 8b 88 20 14 00 00 48 8b 38 5d ff e1 55 48 89  H.. ...H.8]..UH.
0x7fff3fc708bc  e5 48 89 f2 89 fe 65 48 8b 04 25 f0 00 00 00 48  .H....eH..%....H
0x7fff3fc708cc  8b 88 28 14 00 00 48 8b 38 5d ff e1 55 48 89 e5  ..(...H.8]..UH..

=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at System.Object:wrapper_native_0x10f8b4820 <0x00093>
      at SkiaSharp.SkiaApi:sk_refcnt_safe_unref <0x00091>
      at SkiaSharp.SKObjectExtensions:SafeUnRef <0x000ea>
      at SkiaSharp.SKObject:DisposeNative <0x000c2>
      at SkiaSharp.SKNativeObject:Dispose <0x000ab>
      at SkiaSharp.SKObject:Dispose <0x0004a>
      at SkiaSharp.GRContext:Dispose <0x0004a>
      at SkiaSharp.SKNativeObject:Finalize <0x00041>
      at System.Object:runtime_invoke_virtual_void__this__ <0x000ab>
=================================================================
[1]    39765 abort      mono MyApp.exe

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
kekekekscommented, Aug 1, 2020

@mattleibow yes it does try to free resources. No, we can not call AbandonContext, because it happens when user code calls Environment.Exit or just exits Main. Avalonia code does not know that application is about to do that and therefore can not call AbandonContext beforehand.

When application exits Main Mono is calling finalizers for all finalizable objects.

1reaction
kekekekscommented, Aug 1, 2020

It can be illustrated by this example:

    class Finalizable
    {
        ~Finalizable()
        {
            Console.WriteLine("Finalized");
        }

        public void DoSometing()
        {
            Console.WriteLine("Do something");
        }
    }
    
    static class SomeClassWithCachedFinalizable
    {
        static Finalizable _staticInstance = new Finalizable();
        public static void DoSomething()
        {
            _staticInstance.DoSometing();
        }
    }
    
    class Program
    {
        static void Main(string[] args)
        {
            SomeClassWithCachedFinalizable.DoSomething();
        }
    }

As you can see here, SomeClassWithCachedFinalizable is not notified when application is exiting and that it should dispose the finalizable in a controlled manner. Same happens to Avalonia code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KevinEady/macosx-avalonia-net48-skia-crash
This repo illustrates the native crash posted below. It is created via the avalonia.mvvm template with some minor modifications for version ...
Read more >
Posts for 'gaming' - linksfor.dev(s)
98%OSS Spotlight - Build amazing cross-platform UI for .NET with Avalonia UI! 90%How I accidentally invented a new type of chess puzzle; 88%BomBer:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found