VS2017 crash with Resharper and PostSharp Tools

dave.parson's Avatar

dave.parson

14 Nov, 2017 01:20 AM

I am troubleshooting a situation where VS2017 15.4.0 will consistently crash with ReSharper 2017.2.2 and PostSharp Tools 5.0.37. Logs from PostSharp, VSIXInstaller, ReSharper, and windbg are attached; and the ReSharper and windbg logs show an error in the finalizer for PostSharp.Patterns.Threading.ThreadAwareAttribute. VS2017 will not crash if PostSharp Tools are uninstalled or if ReSharper is disabled, but I hoped you could take a look to see if you can resolve this incompatibility.

The error can be recreated by creating a Console application, adding a Console.WriteLine to Main, and then removing the unused args from Main. At some point during this process VS consistently encounters the error. The code does not reference PostSharp so it seems to be some background process related to PostSharp Tools which is running into the error.

Thank you.

From windbg.log

--- EXCEPTION #1/2 [NullReferenceException]
Message = “Object reference not set to an instance of an object.”
ExceptionPath = Root.InnerException
ClassName = System.NullReferenceException
HResult = E_POINTER=COR_E_NULLREFERENCE=80004003
Source = PostSharp.Patterns.Threading
StackTraceString = “at PostSharp.Patterns.Threading.ThreadAwareAttribute.Finalize()”
  1. 1 Posted by dave.parson on 16 Nov, 2017 12:44 AM

    dave.parson's Avatar

    PostSharp support, is this being looked at? Just wondering since it is a blocker for us.

  2. Support Staff 2 Posted by PostSharp Techn... on 16 Nov, 2017 12:59 PM

    PostSharp Technologies's Avatar

    Hello,

    We are sorry for the late response. Yes, we're investigating the issue, but didn't reproduce it yet in our environment.
    We would like to ask you to create a full memory dump in windbg (https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/...) and share it with us.

    We will contact you again once we have more information or questions. As a workaround you would need to uninstall/disable PostSharp Tools for now. This will not affect the PostSharp build-time components.

    -alex

  3. Support Staff 3 Posted by PostSharp Techn... on 16 Nov, 2017 04:09 PM

    PostSharp Technologies's Avatar

    Hello,

    The latest update on the issue - we were able to identify what might be causing this exception. We're now working on a fix and we'll let you know once the new build is released.

    (filed as internal issue #15632)

    -alex

  4. 4 Posted by dave.parson on 16 Nov, 2017 06:43 PM

    dave.parson's Avatar

    Thank you for the update!

  5. Support Staff 5 Posted by PostSharp Techn... on 22 Nov, 2017 12:32 PM

    PostSharp Technologies's Avatar

    Hello,

    We're closing the ticket for now as the bug has been internally filed as issue #15632. We will contact you as soon as the bug fix has been released.

    For more details on our support policies and prioritization of bug fixes, please visit https://www.postsharp.net/support/policies

    PostSharp Team

  6. PostSharp Technologies closed this discussion on 22 Nov, 2017 12:32 PM.

  7. PostSharp Technologies re-opened this discussion on 28 Nov, 2017 10:44 AM

  8. Support Staff 6 Posted by PostSharp Techn... on 28 Nov, 2017 10:44 AM

    PostSharp Technologies's Avatar

    Hello,

    I found that the following code could reproduce the issue:

    using System;
    using PostSharp.Patterns.Threading;
    
    namespace ConsoleApp18
    {
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    new ThreadAwareClass();
                }
                catch
                {
                    
                }
    
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
    
        class BaseClass
        {
            public BaseClass()
            {
                throw new Exception();
            }
    
        }
    
        [Synchronized]
        class ThreadAwareClass : BaseClass
        {
            private bool flag;
    
            ~ThreadAwareClass()
            {
                flag = true;
            }
        }
    }
    

    They key is that the base class throws an exception. We did not anticipate this condition and that's why you're getting the exception (I guess). We'll add some code to cope with this situation.

    -gael

  9. Support Staff 7 Posted by PostSharp Techn... on 04 Dec, 2017 05:24 PM

    PostSharp Technologies's Avatar

    Hello,

    The bug #15632 has been fixed in the current release of PostSharp 5.0.40. Please update the PostSharp Visual Studio extension and NuGet packages to the latest version.
    Should you need further help with this issue, don't hesitate to re-open this discussion.

    -alex

  10. PostSharp Technologies closed this discussion on 04 Dec, 2017 05:24 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac