Unhandled exception when application is finishing
<p>I have a singleton (I know that is a bad pattern). To control the cleaning process, I'm using a shared pointer. The relevant code is:</p>

<pre><code>#ifndef _GLOBAL_LOG_H_
#define _GLOBAL_LOG_H_

    namespace glog{

        class CGlobalLog;
        typedef boost::shared_ptr&lt;CGlobalLog&gt; globalLogPtr;

        class CGlobalLog
        {
        private:

            static globalLogPtr m_instance;
            LogLevel minimiumLogLevel;
            CGlobalLog(void);

            static void deleter(CGlobalLog *ptr){
                try{
                    delete ptr;
                }
                catch(std:: e)
                {
                    std::cout &lt;&lt; e.what() &lt;&lt; "\n";
                }
            }
            static void create() { m_instance.reset( new CGlobalLog, &amp;CGlobalLog::deleter );   }  
            void addMessage_(const std::string&amp; appender, LogLevel level /*= LOGLEVEL_INFO*/,const char* msg, va_list args );
            ~CGlobalLog(void);
        public:         
            static globalLogPtr&amp; getInstance();
            void addMessage(const std::string&amp; message, std::string appender, LogLevel level = LOGLEVEL_INFO);

        };
        globalLogPtr CGlobalLog::m_instance;
    };

#endif // _GLOBAL_LOG_H_
</code></pre>

<p>The program works fine, but when program finish, an unhandled exception is thrown in this point:</p>

<pre><code>static void deleter(CGlobalLog *ptr){
    try{
        delete ptr; //&lt;-- Unhandled exception
    }
    catch(std:: e)
    {
        std::cout &lt;&lt; e.what() &lt;&lt; "\n";
    }
}
</code></pre>

<p>The catch doesn't catch the exception so I don't know what to do to profile my error. The exact code where error is throw is a boost library file checked_delete.hpp, here:</p>

<pre><code>// verify that types are complete for increased safety

template&lt;class T&gt; inline void checked_delete(T * x)
{
    // intentionally complex - simplification causes regressions
    typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
    (void) sizeof(type_must_be_complete);
    delete x;
}
</code></pre>

<p>How do I need to locate this error? Some ideas?</p>

<p>Thanks!!!</p>
