[fixed] NRE on application exit (2 Viewers)

breese

Retired Team Member
  • Premium Supporter
  • July 11, 2011
    3,902
    770
    65
    Arlington Heights, Illinois
    Home Country
    United States of America United States of America
    When I did the test yesterday I set MP2 Client to minimize.
    I just went back onto my machine, opened up the minimized client and then told it to close...
    When I did I got an error message
    MP2 Stopped.jpg

    The file MP2 Stopped Working is the text from the Popup and the 3 Application Events registered.
    I can only assume it is related to the new file and test from yesterday because I have never had this happen before.
     

    Attachments

    • MP2 Stopped Working.txt
      6.6 KB

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Thanks for reporting! I've experienced the same message when testing yesterday. Nice that you have the stacktrace, it makes debugging easier.

    I will look into this issue.

    Edit: Moved report into own thread
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    @MJGraf, I found the issue. It comes from the finalizer of the AMQ: it might happen after the ServiceRegistration finalizer was called.

    Then the access to ServiceRegistration.Get<> will lead to a NRE, because "_instance" was set to null already.
    at MediaPortal.Common.ServiceRegistration.Get[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Boolean)
    at MediaPortal.Common.Messaging.MessageQueueBase.UnregisterFromAllMessageChannels()
    at MediaPortal.Common.Messaging.AsynchronousMessageQueue.Terminate()
    at MediaPortal.Common.Messaging.AsynchronousMessageQueue.Dispose()
    at MediaPortal.Common.Messaging.MessageQueueBase.Finalize()

    A possible solution would be to simply remove the ~ServiceRegistration { Dispose(); } call. What do you think?
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Good spot!
    I always asked myself why we have a destructor which calls Dispose() and dispose does nothing but setting our singleton instance to null.
    If we want to do this, we should follow a proper dispose-pattern - which we did not. But since ServiceRegistration itself does not hold any non-managed resources, I think it should be safe to remove the destructor.
    Just to mention it - There is (at least) one more thing that is strange with our ServiceRegistration:
    There is a property called IsShuttingDown, which defaults to "false". In the ApplicationLauncher's Stop() method, we set it to true with the comment "Block ServiceRegistration from trying to load new services in shutdown phase". But ServiceRegistration does not care at all about this property...
     

    Users who are viewing this thread

    Top Bottom