[Mono-list] Mono does not include full stacktrace while rethrowing exception

Bernhard Urban beurba at microsoft.com
Tue Jun 21 17:55:26 UTC 2016


You can try to run mono without inlining: `mono -O=-inline [...]'


________________________________
From: mono-list-bounces at lists.ximian.com <mono-list-bounces at lists.ximian.com> on behalf of Alan <alan.mcgovern at gmail.com>
Sent: Tuesday, June 21, 2016 2:33 AM
To: Алексей Богомолов
Cc: Mono List
Subject: Re: [Mono-list] Mono does not include full stacktrace while rethrowing exception

This happens on .NET too. This gives a good description of what's happening and why.

http://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx<https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fwww.hanselman.com%2fblog%2fReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx&data=01%7c01%7cbeurba%40microsoft.com%7cf5f2327fd4a34d18817208d399b71770%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=OW3ca33WcWiqD83Jujdu9dArjwARXrWC5ssdRcMU0CU%3d>

Alan

On 21 June 2016 at 09:31, Алексей Богомолов <horse315 at gmail.com<mailto:horse315 at gmail.com>> wrote:

This behavior makes difficult to troubleshoot errors, especially in external libraries. Example code:

public class ExceptionReThrow
{
    public void Test(){
        try
        {
            M1 ();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }

    public void M1()
    {
        M2();
    }

    private void M2()
    {
        try{
            M3();
        }catch{
            throw;
        }
    }

    private void M3()
    {
        throw new NotImplementedException();
    }
}

For Microsoft .Net output will be:

System.NotImplementedException: The method or operation is not implemented. at TestApp.ExceptionReThrow.M3() in D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 38 at TestApp.ExceptionReThrow.M2() in D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 32 at TestApp.ExceptionReThrow.M1() in D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 24 at TestApp.ExceptionReThrow.Test() in D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 14

For mono (4.2.3) output will be:

System.NotImplementedException: The method or operation is not implemented. at TestApp.ExceptionReThrow.M3 () [0x00001] in D:\source\TestApp\TestApp\ExceptionReThrow.cs:38 at TestApp.ExceptionReThrow.M2 () [0x00003] in D:\source\TestApp\TestApp\ExceptionReThrow.cs:30

As you can see, mono looses stack between first and second catch statements. What is the explanation for this feature? Can I disable it?





_______________________________________________
Mono-list maillist  -  Mono-list at lists.ximian.com<mailto:Mono-list at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/mono-list<https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.ximian.com%2fmailman%2flistinfo%2fmono-list&data=01%7c01%7cbeurba%40microsoft.com%7cf5f2327fd4a34d18817208d399b71770%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=HCjwCdQLyKc7gIOR1gMdBebupL2mSvlwxQGIGcDvYGM%3d>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20160621/8d140916/attachment.html>


More information about the Mono-list mailing list