Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:08:53+00:00 2026-06-17T19:08:53+00:00

There are plenty iOS crash reporting libraries in iOS, including TestFlight and HockeyApp .

  • 0

There are plenty iOS crash reporting libraries in iOS, including TestFlight and HockeyApp. If you don’t want to depend on services, you can still use libraries like PLCrashReporter. Binding these libraries is fairly trivial because their public API usually consists of a couple of classes with several initialization methods.

However, when trying to use TestFlight, and later HockeyApp in our application, our app began to randomly crash. Turns out, this is a known issue reported several times, but Xamarin doesn’t warn about it, it is relatively obscure and we found it the hard way.

We have learned that all iOS crash reporters prevent Mono from catching null reference exceptions:

try {
    object o = null;
    o.GetHashCode ();
} catch {
    // Catch block isn't called with crash reporting enabled.
    // Instead, the app will crash.
}

Why does this happen? Quoting Rolf, a Xamarin developer,

A null reference exception is actually a SIGSEGV signal at first. Usually the
mono runtime handles this and translates it into a nullreference exception,
allowing the execution to continue. The problem is that SIGSEGV signals are a
very bad thing in ObjC apps (and when it occurs outside of managed code), so
any crash reporting solution will report it as a crash (and kill the app) –
this happens before MonoTouch gets a chance to handle the SIGSEGV, so there is
nothing MonoTouch can do about this.

I’m sure many use TestFlight in MonoTouch apps without knowing it causes crashes.
Isn’t it ironic?

How do you make crash reporting libraries not crash MonoTouch apps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:08:54+00:00Added an answer on June 17, 2026 at 7:08 pm

    Put this in AppDelegate.cs:

    [DllImport ("libc")]
    private static extern int sigaction (Signal sig, IntPtr act, IntPtr oact);
    
    enum Signal {
        SIGBUS = 10,
        SIGSEGV = 11
    }
    
    static void EnableCrashReporting ()
    {
        IntPtr sigbus = Marshal.AllocHGlobal (512);
        IntPtr sigsegv = Marshal.AllocHGlobal (512);
    
        // Store Mono SIGSEGV and SIGBUS handlers
        sigaction (Signal.SIGBUS, IntPtr.Zero, sigbus);
        sigaction (Signal.SIGSEGV, IntPtr.Zero, sigsegv);
    
        // Enable crash reporting libraries
        EnableCrashReportingUnsafe ();
    
        // Restore Mono SIGSEGV and SIGBUS handlers            
        sigaction (Signal.SIGBUS, sigbus, IntPtr.Zero);
        sigaction (Signal.SIGSEGV, sigsegv, IntPtr.Zero);
    
        Marshal.FreeHGlobal (sigbus);
        Marshal.FreeHGlobal (sigsegv);
    }
    
    static void EnableCrashReportingUnsafe ()
    {
        // Run your crash reporting library initialization code here--
        // this example uses HockeyApp but it should work well
        // with TestFlight or other libraries.
    
        // Verify in documentation that your library of choice
        // installs its sigaction hooks before leaving this method.
    
        var manager = BITHockeyManager.SharedHockeyManager;
        manager.Configure (HockeyAppId, null);
        manager.StartManager ();
    }
    

    Call EnableCrashReporting () in the beginning of FinishedLaunching method.
    Wrap this call in #if !DEBUG directive if you want.


    How does it work?

    I followed Rolf’s suggestion:

    One possible solution is to allow mono to handle all SIGSEGV signals
    (technically speaking the crash reporting lib should either not handle
    the SIGSEGV signal, or it should chain to mono’s handler and not do
    any processing by itself). If mono determines that the SIGSEGV signal
    is not from managed code (i.e. something very bad happened), it will
    raise a SIGABORT signal (which the crash reporting lib should already
    handle and treat as a crash). As you can understand this is something
    that has to be done in the crash reporting library.

    And Landon Fuller‘s Objective C implementation:

    #import <signal.h>
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        /* Save Mono's signal handler actions */
        struct sigaction sigbus_action, sigsegv_action;
        sigaction(SIGBUS, NULL, &sigbus_action);
        sigaction(SIGSEGV, NULL, &sigsegv_action);
    
        // Enable the crash reporter here. Ie, [[PLCrashReporter sharedReporter] enableCrashReporterAndReturnError:],
        // or whatever is the correct initialization mechanism for the crash reporting service you're using
    
        /* Restore Mono's signal handlers */
        sigaction(SIGBUS, &sigbus_action, NULL);
        sigaction(SIGSEGV, &sigsegv_action, NULL);
    
        return YES;
    }
    

    I used Banshee source code as a reference point for how to call sigaction from MonoTouch.

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are plenty of options for powerful server side languages, but I can't think
There's plenty of information on running Java apps as services, but I need to
There are plenty of 'pretty-printing' visualization libraries for Javascript. E.g. those listed here. Googling
There are plenty of similar questions to be found on here but I don't
There are plenty of questions of how to use CheckedTextView but I can't make
There are plenty of articles on the web detailing why you might not want
There are plenty of tutorials for == and === so please don't guide me
There are plenty of threads and documentation about parallel ssh, but I can't find
There are plenty of examples of sending data to SugarCRM via a web-service, but
There are plenty of PHP frameworks out there as many of you know, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.