Bug 27343 - Exception during finalization results in crash with no crash diagnostics
Summary: Exception during finalization results in crash with no crash diagnostics
Status: RESOLVED DUPLICATE of bug 26786
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-24 04:39 UTC by Kent
Modified: 2015-02-24 06:09 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 26786

Description Kent 2015-02-24 04:39:20 UTC
If one accidentally throws an exception during finalization, the runtime just seems to get ripped straight out and there is no crash log or debug output. This can make it very challenging to track down. Breakpoints in the finalizer/dispose logic seem to work on the device, but not in the simulator. Break on exception only seems to work on the device.

The crash occurs on both simulator and device, although I had to exacerbate the issue on device by repeating the repro several times.

Here is the repro (in test form):

[Fact]
public void repro()
{
    BadClass.Create();
    GC.Collect();
    GC.WaitForPendingFinalizers();
}

private class BadClass : IDisposable
{
    private string foo;

    public static void Create()
    {
        new BadClass();
    }

    ~BadClass()
    {
        this.Dispose();
    }

    public void Dispose()
    {
        // oops
        if (foo.Length == 0)
        {

        }
    }
}
Comment 1 Kent 2015-02-24 04:47:16 UTC
PS. I'm running VS2015 CTP6. Didn't try in XS.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-02-24 06:09:41 UTC

*** This bug has been marked as a duplicate of bug 26786 ***