Teg, On Sun, Jan 31, 2016 at 12:29 AM, Igor Korot <ikorot01 at gmail.com> wrote: > Teg, > > On Sat, Jan 30, 2016 at 1:54 PM, Teg <Teg at djii.com> wrote: >> Hello Igor, > > This is all compiling with /MTd. > >> >> I might set a break point in the destructor for the DB class and make >> sure it's not being fired before the exit crash. Question marks on a >> pointer means it's an invalid pointer. The pointer to DB might be >> incorrect or the pointer to something inside the DB class might be >> incorrect. Sounds almost like it's getting destructed twice. > > No, the breakpoint is hit only once. > >> >> What happens if you new the DB class then use it, then immediately >> delete it? Does it still crash? > > Apparently yes. It still crashes. > However, it does go thru the destructor and then crashes. > > Here is the stack trace of the crash: > ntdll.dll!77b973a6() > [Frames below may be incorrect and/or missing, no symbols loaded > for ntdll.dll] > ntdll.dll!77b5164f() > ntdll.dll!77b20f01() > KernelBase.dll!762b2844() >> sqlite.dll!_CrtIsValidHeapPointer(const void * pUserData) Line 2036 >> C++ > sqlite.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) > Line 1322 + 0x9 bytes C++ > sqlite.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 > + 0xd bytes C++ > sqlite.dll!operator delete(void * pUserData) Line 54 + 0x10 bytes C++ > sqlite.dll!SQLiteDatabase::`vector deleting destructor'() + 0x65 > bytes C++ > dialogs.dll!DatabaseType::OnConnect(wxWizardEvent & __formal) > Line 125 + 0x3a bytes C++ > dialogs.dll!wxAppConsoleBase::HandleEvent(wxEvtHandler * handler, > void (wxEvent &)* func, wxEvent & event) Line 657 + 0xf bytes C++ > dialogs.dll!wxAppConsoleBase::CallEventHandler(wxEvtHandler * > handler, wxEventFunctor & functor, wxEvent & event) Line 669 + 0x22 > bytes C++ > dialogs.dll!wxEvtHandler::ProcessEventIfMatchesId(const > wxEventTableEntryBase & entry, wxEvtHandler * handler, wxEvent & > event) Line 1383 + 0x29 bytes C++ > dialogs.dll!wxEvtHandler::SearchDynamicEventTable(wxEvent & > event) Line 1775 + 0x11 bytes C++ > dialogs.dll!wxEvtHandler::TryHereOnly(wxEvent & event) Line 1576 > + 0x15 bytes C++ > dialogs.dll!wxEvtHandler::TryBeforeAndHere(wxEvent & event) Line > 3656 + 0x2d bytes C++ > dialogs.dll!wxEvtHandler::ProcessEventLocally(wxEvent & event) > Line 1513 + 0xc bytes C++ > dialogs.dll!wxEvtHandler::ProcessEvent(wxEvent & event) Line > 1486 + 0xc bytes C++ > dialogs.dll!wxWizard::ShowPage(wxWizardPage * page, bool > goingForward) Line 577 + 0x2a bytes C++ > dialogs.dll!wxWizard::OnBackOrNext(wxCommandEvent & event) Line > 818 + 0x1e bytes C++ > dialogs.dll!wxAppConsoleBase::HandleEvent(wxEvtHandler * handler, > void (wxEvent &)* func, wxEvent & event) Line 657 + 0xf bytes C++ > dialogs.dll!wxAppConsoleBase::CallEventHandler(wxEvtHandler * > handler, wxEventFunctor & functor, wxEvent & event) Line 669 + 0x22 > bytes C++ > dialogs.dll!wxEvtHandler::ProcessEventIfMatchesId(const > wxEventTableEntryBase & entry, wxEvtHandler * handler, wxEvent & > event) Line 1383 + 0x29 bytes C++ > dialogs.dll!wxEventHashTable::HandleEvent(wxEvent & event, > wxEvtHandler * self) Line 989 + 0x11 bytes C++ > dialogs.dll!wxEvtHandler::TryHereOnly(wxEvent & event) Line 1580 > + 0x25 bytes C++ > dialogs.dll!wxEvtHandler::TryBeforeAndHere(wxEvent & event) Line > 3656 + 0x2d bytes C++ > dialogs.dll!wxEvtHandler::ProcessEventLocally(wxEvent & event) > Line 1513 + 0xc bytes C++ > dialogs.dll!wxEvtHandler::ProcessEvent(wxEvent & event) Line > 1486 + 0xc bytes C++ > dialogs.dll!wxWindowBase::TryAfter(wxEvent & event) Line 3456 + > 0x1e bytes C++ > dialogs.dll!wxEvtHandler::ProcessEvent(wxEvent & event) Line > 1499 + 0x13 bytes C++ > dialogs.dll!wxEvtHandler::SafelyProcessEvent(wxEvent & event) > Line 1604 + 0x13 bytes C++ > dialogs.dll!wxWindowBase::HandleWindowEvent(wxEvent & event) > Line 1543 C++ > dialogs.dll!wxControl::ProcessCommand(wxCommandEvent & event) > Line 289 C++ > dialogs.dll!wxButton::SendClickEvent() Line 367 + 0xc bytes C++ > dialogs.dll!wxButton::MSWCommand(unsigned int param, unsigned > short __formal) Line 415 + 0x8 bytes C++ > dialogs.dll!wxWindow::HandleCommand(unsigned short id_, unsigned > short cmd, HWND__ * control) Line 5169 + 0x1c bytes C++ > dialogs.dll!wxWindow::MSWHandleMessage(long * result, unsigned > int message, unsigned int wParam, long lParam) Line 2905 + 0x1f bytes > C++ > dialogs.dll!wxWindow::MSWWindowProc(unsigned int message, > unsigned int wParam, long lParam) Line 3471 + 0x22 bytes C++ > dialogs.dll!wxTopLevelWindowMSW::MSWWindowProc(unsigned int > message, unsigned int wParam, long lParam) Line 321 + 0x14 bytes > C++ > dialogs.dll!wxDialog::MSWWindowProc(unsigned int message, > unsigned int wParam, long lParam) Line 351 + 0x14 bytes C++ > dialogs.dll!wxWndProc(HWND__ * hWnd, unsigned int message, > unsigned int wParam, long lParam) Line 2649 + 0x1e bytes C++ > user32.dll!76018e71() > user32.dll!760190d1() > user32.dll!76018fce() > user32.dll!76019333() > user32.dll!760477ce() > user32.dll!76033d0b() > user32.dll!76033ebf() > dialogs.dll!wxWindow::MSWSafeIsDialogMessage(tagMSG * msg) Line > 2544 + 0x15 bytes C++ > dialogs.dll!wxWindow::MSWProcessMessage(tagMSG * pMsg) Line 2428 > + 0xc bytes C++ > dialogs.dll!wxGUIEventLoop::PreProcessMessage(tagMSG * msg) Line > 147 + 0x16 bytes C++ > dialogs.dll!wxGUIEventLoop::ProcessMessage(tagMSG * msg) Line > 165 + 0x13 bytes C++ > dialogs.dll!wxGUIEventLoop::Dispatch() Line 229 + 0x13 bytes C++ > dialogs.dll!wxEventLoopManual::ProcessEvents() Line 228 + 0xf bytes > C++ > dialogs.dll!wxEventLoopManual::DoRun() Line 273 + 0x8 bytes C++ > dialogs.dll!wxEventLoopBase::Run() Line 76 + 0xf bytes C++ > dialogs.dll!wxDialogModalData::RunLoop() Line 62 + 0xf bytes C++ > dialogs.dll!wxDialog::ShowModal() Line 194 C++ > dialogs.dll!wxWizard::RunWizard(wxWizardPage * firstPage) Line > 698 + 0x12 bytes C++ > dialogs.dll!DatabaseProfile(wxWindow * parent, const wxString & > title, Database * db, wxString & dbEngine) Line 96 + 0x17 bytes > C++ > docview.exe!MainFrame::OnDatabaseProfile(wxCommandEvent & > __formal) Line 105 + 0x60 bytes C++ > docview.exe!wxAppConsoleBase::HandleEvent(wxEvtHandler * handler, > void (wxEvent &)* func, wxEvent & event) Line 657 + 0xf bytes C++ > docview.exe!wxAppConsoleBase::CallEventHandler(wxEvtHandler * > handler, wxEventFunctor & functor, wxEvent & event) Line 669 + 0x22 > bytes C++ > docview.exe!wxEvtHandler::ProcessEventIfMatchesId(const > wxEventTableEntryBase & entry, wxEvtHandler * handler, wxEvent & > event) Line 1383 + 0x29 bytes C++ > docview.exe!wxEventHashTable::HandleEvent(wxEvent & event, > wxEvtHandler * self) Line 989 + 0x11 bytes C++ > docview.exe!wxEvtHandler::TryHereOnly(wxEvent & event) Line 1580 > + 0x25 bytes C++ > docview.exe!wxEvtHandler::TryBeforeAndHere(wxEvent & event) Line > 3656 + 0x2d bytes C++ > docview.exe!wxEvtHandler::ProcessEventLocally(wxEvent & event) > Line 1513 + 0xc bytes C++ > docview.exe!wxEvtHandler::ProcessEvent(wxEvent & event) Line > 1486 + 0xc bytes C++ > docview.exe!wxWindowBase::TryAfter(wxEvent & event) Line 3456 + > 0x1e bytes C++ > docview.exe!wxEvtHandler::ProcessEvent(wxEvent & event) Line > 1499 + 0x13 bytes C++ > docview.exe!wxEvtHandler::SafelyProcessEvent(wxEvent & event) > Line 1604 + 0x13 bytes C++ > docview.exe!wxWindowBase::HandleWindowEvent(wxEvent & event) > Line 1543 C++ > docview.exe!wxToolBarBase::OnLeftClick(int toolid, bool > toggleDown) Line 651 C++ > docview.exe!wxToolBar::MSWCommand(unsigned int __formal, unsigned > short id_) Line 1310 + 0x1b bytes C++ > docview.exe!wxWindow::HandleCommand(unsigned short id_, unsigned > short cmd, HWND__ * control) Line 5169 + 0x1c bytes C++ > docview.exe!wxFrame::HandleCommand(unsigned short id, unsigned > short cmd, HWND__ * control) Line 819 C++ > docview.exe!wxFrame::MSWWindowProc(unsigned int message, unsigned > int wParam, long lParam) Line 856 C++ > docview.exe!wxWndProc(HWND__ * hWnd, unsigned int message, > unsigned int wParam, long lParam) Line 2649 + 0x1e bytes C++ > user32.dll!76018e71() > user32.dll!760190d1() > user32.dll!76018fce() > user32.dll!760477ce() > user32.dll!76022b39() > user32.dll!7601a680() > docview.exe!wxGUIEventLoop::ProcessMessage(tagMSG * msg) Line > 169 + 0xc bytes C++ > docview.exe!wxGUIEventLoop::Dispatch() Line 229 + 0x13 bytes C++ > docview.exe!wxEventLoopManual::ProcessEvents() Line 228 + 0xf bytes > C++ > docview.exe!wxEventLoopManual::DoRun() Line 273 + 0x8 bytes C++ > docview.exe!wxEventLoopBase::Run() Line 76 + 0xf bytes C++ > docview.exe!wxAppConsoleBase::MainLoop() Line 380 + 0x27 bytes C++ > docview.exe!wxAppConsoleBase::OnRun() Line 301 + 0x12 bytes C++ > docview.exe!wxAppBase::OnRun() Line 312 C++ > docview.exe!wxEntryReal(int & argc, wchar_t * * argv) Line 503 + > 0x1d bytes C++ > docview.exe!wxEntry(int & argc, wchar_t * * argv) Line 181 + 0xd > bytes C++ > docview.exe!wxEntry(HINSTANCE__ * hInstance, HINSTANCE__ * > __formal, HINSTANCE__ * __formal, int nCmdShow) Line 289 + 0x10 bytes > C++ > docview.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * > hPrevInstance, char * __formal, int nCmdShow) Line 76 + 0x16 bytes > C++ > docview.exe!__tmainCRTStartup() Line 275 + 0x2c bytes C > docview.exe!WinMainCRTStartup() Line 189 C > kernel32.dll!758a7c04() > ntdll.dll!77b0ad6f() > ntdll.dll!77b0ad3a() > > > I basically called new, then ask the database for the list of tables, > then disconnected and deleted the pointer. > All this is done in one dynamically linked library. > > I can try to do the same with /MDd just to completeness.
Ok, I did try to recompile everything with /MDd. The crash again happens only on the main frame destruction. Everything worked after the pointer had been assigned to the main frame member. I don't understand this at all. Thank you. > > Thank you. > >> >> C >> >> >> Friday, January 29, 2016, 10:59:53 PM, you wrote: >> >> IK> Teg, >> >> IK> On Fri, Jan 29, 2016 at 6:43 AM, Teg <Teg at djii.com> wrote: >>>> Hello Igor, >>>> >>>> I'm probably go the opposite direction and make sure everything is >>>> built /MDd or /MD. Basically dynamic link the whole thing. It means >>>> all of your projects need to be rebuilt using the same RTL though. >>>> >>>> You just don't want 1/2 to be /MT and the other 1/2 to be /MD. >> >> IK> Everything was build successfully with /MDd. It only crashed on the >> program exit >> IK> (main frame close). >> >> IK> Now I temporarily remove all references to odbc sql*.h - it did compile >> and link >> IK> fine, but it crashed again at the same place. >> >> IK> Now when running with /MTd I see that everything is assigned correctly, >> however >> the call to db->>Disconnect() fails and the sqlite pointer is not >> IK> correct it is (????) under >> IK> the debugger. However, running with /MDd, everything was passed >> correctly. >> >> IK> Any idea? >> >> IK> Thank you. >> >>>> >>>> >>>> >>>> C >>>> >>>> Thursday, January 28, 2016, 11:25:10 PM, you wrote: >>>> >>>> IK> Hi, ALL, >>>> >>>> >>>> IK> On Tue, Jan 26, 2016 at 3:08 PM, Clemens Ladisch <clemens at >>>> ladisch.de> wrote: >>>>>> Igor Korot wrote: >>>>>>> sqlite.dll!sqlite3_mutex_enter(sqlite3_mutex * p) Line 19996 + >>>>>>> 0xc bytes C >>>>>>> sqlite.dll!sqlite3Close(sqlite3 * db, int forceZombie) Line 726 + >>>>>>> 0xc bytes C >>>>>>> sqlite.dll!sqlite3_close(sqlite3 * db) Line 772 + 0xe bytes C >>>>>>> sqlite.dll!SQLiteDatabase::Disconnect(...) Line 51 + 0xc bytes >>>>>>> C++ >>>>>>> dialogs.dll!DisconnectFromDb(Database * db) Line 108 + 0x13 bytes >>>>>>> C++ >>>>>>> docview.exe!MainFrame::~MainFrame() Line 73 + 0xf bytes C++ >>>>>>> docview.exe!MainFrame::`scalar deleting destructor'() + 0x16 >>>>>>> bytes C++ >>>>>>> docview.exe!wxAppConsoleBase::DeletePendingObjects() Line 637 + >>>>>>> 0x23 bytes C++ >>>>>>> docview.exe!wxAppConsoleBase::ProcessIdle() Line 445 C++ >>>>>> >>>>>> This looks OK. >>>>>> >>>>>> Are you ever calling sqlite3_shutdown()? >>>>>> Are you calling sqlite3_close() from more than one place, or more than >>>>>> once? >>>>>> (Add logging to find out.) >>>> >>>> IK> I tried to recompile the project with the /MTd, but I got this: >>>> >>>> 1>>odbccp32.lib(dllload.obj) : error LNK2019: unresolved external >>>> IK> symbol __imp___vsnprintf referenced in function >>>> IK> _StringVPrintfWorkerA at 20 >>>> >>>> IK> And here is my Linker Project Settings: >>>> >>>> IK> >>>> odbccp32.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.l? >>>> IK> >>>> ib;shell32.lib;shlwapi.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.li? >>>> IK> >>>> b;advapi32.lib;version.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) >>>> >>>> IK> Is there an easy way to fix this? >>>> >>>> IK> Thank you. >>>> >>>>>> >>>>>> >>>>>> Regards, >>>>>> Clemens >>>>>> _______________________________________________ >>>>>> sqlite-users mailing list >>>>>> sqlite-users at mailinglists.sqlite.org >>>>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >>>> IK> _______________________________________________ >>>> IK> sqlite-users mailing list >>>> IK> sqlite-users at mailinglists.sqlite.org >>>> IK> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >>>> >>>> >>>> >>>> -- >>>> Teg mailto:Teg at djii.com >>>> >> >> >> >> -- >> Teg mailto:Teg at djii.com >>