Weird crash on MSW

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3464
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Weird crash on MSW

Post by ONEEYEMAN » Sun Jun 09, 2019 7:45 pm

Hi, ALL,
First about my environment(s):

wxWidgets 3.1.1
- Windows: MSVC 2017 Community Edition with default debug build (no setup changes) Windows version is 8.1
- *nix: Anjuta with gcc-5.4 built against GTK+3 (self-compiled)
- OSX: 10.8 with XCode/clang (c++11), again default debug build.

What's strange is that my program crashes on Windows when I click the "X" button of the main frame (on exit).
This does not happen on both *nix and Mac.

The crash happens somewhere inside wxWidgets, but I can't see where because of this.

So basically the backtrace window of MSVC shows many frames with the wxmsw311ud_core on top, but the editor window shows the end of the main frame constructor.

It would be very nice to fix the crash on Windows, but I don't even know where to start, since I don't know where the crash is.

Could someone please help? Even if you suggest on how to fix the debugging symbols...

Thank you.

Kvaz1r
Earned some good credits
Earned some good credits
Posts: 128
Joined: Tue Jun 07, 2016 1:07 pm

Re: Weird crash on MSW

Post by Kvaz1r » Sun Jun 09, 2019 7:57 pm

Try write MCVE and maybe it'll became obvious. I don't think it's possible to say something without code.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3464
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Weird crash on MSW

Post by ONEEYEMAN » Sun Jun 09, 2019 8:04 pm

Hi,
Thank you for the reply.
Did you look at my SO post? Any idea why MSVC does not see the pdb files from wx?

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14076
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Weird crash on MSW

Post by doublemax » Sun Jun 09, 2019 9:28 pm

What happens if you (at least temporarily) switch to static linking? Does it crash, too? If yes, you should get a proper call stack.

And the obvious question: Does it happen in any of the samples?

Do you have a close event handler? If yes, can you show it?
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3464
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Weird crash on MSW

Post by ONEEYEMAN » Mon Jun 10, 2019 4:33 am

Doublemax,
doublemax wrote:
Sun Jun 09, 2019 9:28 pm
What happens if you (at least temporarily) switch to static linking? Does it crash, too? If yes, you should get a proper call stack.
I can try, but since the program have multiple DLLs and have a secondary thread I don't think it is a good idea.
Its going to be multiple copies of wx from all those DLLs.

Is it OK?
doublemax wrote:
Sun Jun 09, 2019 9:28 pm
And the obvious question: Does it happen in any of the samples?
And the obvious answer - no. Neither in DLL, nor in thread one.
doublemax wrote:
Sun Jun 09, 2019 9:28 pm
Do you have a close event handler? If yes, can you show it?
Here it is:

Code: Select all

void MainFrame::OnClose(wxCloseEvent &WXUNUSED(event))
{
    if( m_db )
    {
#if defined _DEBUG
        printf( "Starting MainFrame::OnClose\n\r" );
#endif
        {
            std::lock_guard<std::mutex>( m_db->GetTableVector().my_mutex );
            if( m_handler )
            {
#if defined _DEBUG
                printf( "Deleting the thread...\n\r" );
#endif
                if( m_handler->Delete() != wxTHREAD_NO_ERROR )
                {
                }
            }
        }
        while( 1 )
        {
#if defined _DEBUG
            printf( "Looping for thread deletionn\n\r" );
#endif
            {
                std::lock_guard<std::mutex>( m_db->GetTableVector().my_mutex );
                if( !m_handler )
                    break;
            }
            wxThread::This()->Sleep( 1 );
        }
#if defined _DEBUG
        printf( "Thread destroyed. Deleting application....\n\r" );
#endif
    }
    Destroy();
}
Nothing fancy. And of course this:

Code: Select all

MainFrame::~MainFrame()
{
    std::vector<std::wstring> errorMsg;
    int result = 0;
    wxConfigBase *config = wxConfigBase::Get( "DBManager" );
    wxString path = config->GetPath();
    config->SetPath( "CurrentDB" );
    if( m_db )
    {
        wxString temp1( m_db->GetTableVector().m_type );
        config->Write( "Engine", temp1 );
        wxString temp2 = m_db->GetTableVector().m_subtype;
        config->Write( "Subtype", temp2 );
        if( temp2 == "PostgreSQL" )
        {
            wxString temp3( m_db->GetTableVector().GetPostgreLogFile() );
            config->Write( "Logfile", temp3 );
        }
        std::lock_guard<std::mutex>( m_db->GetTableVector().my_mutex );
        result = m_db->Disconnect( errorMsg );
    }
    if( result )
    {
        for( std::vector<std::wstring>::iterator it = errorMsg.begin(); it < errorMsg.end(); it++ )
        {
            wxMessageBox( (*it) );
        }
    }
    delete m_db;
    m_db = NULL;
    for( std::map<wxString, wxDynamicLibrary *>::iterator it = m_painters.begin(); it != m_painters.end(); ++it )
    {
        delete (*it).second;
        (*it).second = NULL;
    }
}
Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14076
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Weird crash on MSW

Post by doublemax » Mon Jun 10, 2019 6:46 am

I don't see any obvious error. What about the printf() calls, do you see their output? With them you should be able to narrow down where it crashes. If you don't see them, use wxLogDebug instead.
Use the source, Luke!

Post Reply