EmperorArthur / VBA-M

The VBA-M project at http://vba-m.com/ is rarely updated. This is a version that will run without requiring old, unsupported libraries. Please treat it as a testing branch before (some) of the changes filter into the main code base.
Other
8 stars 2 forks source link

"An assertion failed!" in wxvbam #5

Closed andoruB closed 9 years ago

andoruB commented 9 years ago

So running the wx flavour of the vbam GUI gives me "An assertion failed!" followed by:

../src/gtk/scrolwin.cpp(205): assert "scrolled" failed in DoShowScrollbars(): window must be created

Here's the backtrace:

[1] wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility, wxScrollbarVisibility) [2] wxScrolledWindowXmlHandler::DoCreateResource() [3] wxXmlResourceHandlerImpl::CreateResource(wxXmlNode, wxObject, wxObject) [4] wxXmlResource::DoCreateResFromNode(wxXmlNode&, wxObject, wxObject, wxXmlResourceHandler) [5] wxXmlResourceHandlerImpl::CreateResFromNode(wxXmlNode, wxObject, wxObject_) [6] wxSizerXmlHandler::Handlesizeritem() [7] wxSizerXmlHandler::DoCreateResource() [8] wxXmlResourceHandlerImpl::CreateResource(wxXmlNode, wxObject, wxObject) [9] wxXmlResource::DoCreateResFromNode(wxXmlNode&, wxObject, wxObject, wxXmlResourceHandler) [10] wxXmlResourceHandlerImpl::CreateChildren(wxObject, bool) [11] wxSizerXmlHandler::Handlesizer() [12] wxSizerXmlHandler::DoCreateResource() [13] wxXmlResourceHandlerImpl::CreateResource(wxXmlNode, wxObject, wxObject) [14] wxXmlResource::DoCreateResFromNode(wxXmlNode&, wxObject, wxObject, wxXmlResourceHandler) [15] wxXmlResourceHandlerImpl::CreateChildren(wxObject, bool) [16] wxDialogXmlHandler::DoCreateResource() [17] wxXmlResourceHandlerImpl::CreateResource(wxXmlNode, wxObject, wxObject) [18] wxXmlResource::DoCreateResFromNode(wxXmlNode&, wxObject, wxObject, wxXmlResourceHandler) [19] wxXmlResource::DoLoadObject(wxWindow, wxString const&, wxString const&, bool) [20] wxXmlResource::LoadObject(wxWindow, wxString const&, wxString const&) [21] MainFrame::InitMore() [22] wxvbamApp::OnInit() [23] wxAppConsoleBase::CallOnInit() [24] wxEntry(int&, wchar_t_) [25] wxEntry(int&, char*) [26] main [27] __libc_start_main [28] _start

Clicking on "Continue" brings up the GUI with the following error:

21:05:46: Failed to create a temporary file name (error 2: No such file or directory) 21:05:46: can't open user configuration file.

After that the GUI is usable, except when I open menu entries, I get yet another assertion failed error:

ASSERT INFO: /usr/include/wx-3.0/wx/object.h(160): assert "wxDynamicCast(ptr, T)" failed in wxCheckCast(): wxStaticCast() used incorrectly

BACKTRACE: [1] wxDialog* wxCheckCast(void const, wxDialog) [2] MainFrame::DoDisplayConfigure() [3] MainFrame::OnDisplayConfigure(wxCommandEvent&) [4] wxAppConsoleBase::HandleEvent(wxEvtHandler, void (wxEvtHandler::)(wxEvent&), wxEvent&) const [5] wxAppConsoleBase::CallEventHandler(wxEvtHandler, wxEventFunctor&, wxEvent&) const [6] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler, wxEvent&) [7] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler_) [8] wxEvtHandler::TryHereOnly(wxEvent&) [9] wxEvtHandler::ProcessEventLocally(wxEvent&) [10] wxEvtHandler::ProcessEvent(wxEvent&) [11] wxWindowBase::TryAfter(wxEvent&) [12] wxEvtHandler::ProcessEvent(wxEvent&) [13] wxEvtHandler::SafelyProcessEvent(wxEvent&) [14] wxWindowBase::HandleWindowEvent(wxEvent&) const [15] wxMenuBase::SendEvent(int, int) [16] g_cclosure_marshal_VOIDVOID [17] g_closure_invoke [18] g_signal_emit_valist [19] g_signal_emit [20] gtk_widget_activate [21] gtk_menu_shell_activate_item [22] g_closure_invoke [23] g_signal_emit_valist [24] g_signal_emit [25] gtk_propagate_event [26] gtk_main_do_event [27] g_main_context_dispatch [28] g_main_loop_run [29] gtk_main [30] wxGUIEventLoop::DoRun() [31] wxEventLoopBase::Run() [32] wxAppConsoleBase::MainLoop() [33] wxAppConsoleBase::OnRun() [34] wxAppBase::OnRun() [35] wxEntry(int&, wchar_t_) [36] wxEntry(int&, char*) [37] main [38] libc_start_main [39] _start

Clicking on "Continue" closes the GUI/emulator.

This happens to all menu entries, except "Open" and those under the "Emulation" menu.

EmperorArthur commented 9 years ago

Grepping through sources it looks like this line is causing the problem: src/wx/guiinit.cpp:2325

It's part of some strange #define do{...}while(0) loops. Since it's not actually a function call I now need to figure out wtf is going on.

EmperorArthur commented 9 years ago

Ok, I think I have a slightly better understanding of the code now. This is probably the last line of actual wxvbam code that caused the problem.

[20] wxXmlResource::LoadObject(wxWindow, wxString const&, wxString const&)

it's now on guiinit.cpp:2058 dialog = wxDynamicCast(wxXmlResource::Get()->LoadObject(theframe, dname, wxEmptyString), wxDialog);

If you could try setting a gdb breakpoint there and looking at those variables it would be a huge help. Especially since I can't reproduce this at all.

Edit: Changed the line number.

andoruB commented 9 years ago

Could you explain a bit how I set that gdb breakpoint? I'm not at all versed in programming :P

EmperorArthur commented 9 years ago

I've gone ahead and uploaded a build script that should make sure that all of the needed dependencies are installed. Try running that.

After that do this: rm -r build mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Debug .. make gdb ./wxvbam break src/wx/guiinit.cpp:2058 run backtrace next print dialog quit

If you'll paste the output of that it would help a bunch.

andoruB commented 9 years ago

Okay, ran the build script you made, and it seems I was missing a package, namely libwxgtk2.8-dev. But ran the executable, and it was still the same.

Not sure if you needed the output of all the commands you gave me above, or just for gdb, if you need the entire output, I'll gladly handle it to you. For now here's the gdb output: http://pastebin.com/wari6ASq

Also, when I issued next, the "DoShowScrollbars(): window must be created" wx error popped up again, so I assumed I must click on "Continue".

This is so exciting :D

EmperorArthur commented 9 years ago

The most likely issue is that my system uses wx 2.8 instead of 3.0 I'll try to work with it some more on my end, but here are a few suggestions for now.

Try this: sudo apt-get install libwxgtk3.0-dev

Otherwise try:

git fetch git checkout remotes/origin/usewxgtk2

Also if you can try typing "step" a few times instead of next in gdb it will run you through exactly what it's doing before things fail.

andoruB commented 9 years ago

$ apt-get install libwxgtk3.0-dev Reading package lists... Done Building dependency tree
Reading state information... Done libwxgtk3.0-dev is already the newest version.


$ git fetch remote: Counting objects: 5, done. remote: Compressing objects: 100% (5/5), done. remote: Total 5 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (5/5), done. From https://github.com/EmperorArthur/VBA-M x [new branch] usewxgtk2 -> origin/usewxgtk2


$ git checkout remotes/origin/userwxgtk2 error: pathspec 'remotes/origin/userwxgtk2' did not match any file(s) known to git.

As for the steps: http://pastebin.com/acLBQsz6 Did 15 steps, most of them probably unnecessary, but I just wanted to make sure :P

EmperorArthur commented 9 years ago

The reason git complained was "usewxgtk2" vs "userwxgtk2" you snuck an extra 'r' into the git checkout. I just did the same thing, so it's not a big deal.

You can just copy and paste this into your shell: "git fetch -f;git checkout remotes/origin/usewxgtk2"

Otherwise git will complain. If you want to see what I'm doing you can type "git gui&" under "Repository" click "Visualize All Branch History". It's like git log, but easier to read.

andoruB commented 9 years ago

$ git fetch -f;git checkout remotes/origin/usewxgtk2 remote: Counting objects: 10, done. remote: Compressing objects: 100% (10/10), done. remote: Total 10 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (10/10), done. From https://github.com/EmperorArthur/VBA-M aeb0330..30876d2 master -> origin/master

  • c232ccd...40d5fe9 usewxgtk2 -> origin/usewxgtk2 (forced update) M po/gvbam/zh_TW.po M po/wxvbam/cs.po M po/wxvbam/en.po M po/wxvbam/nl.po M po/wxvbam/zh_TW.po Note: checking out 'remotes/origin/usewxgtk2'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

HEAD is now at 40d5fe9... Make sure that wxwidgets uses the gtk2 version of the toolkit

EmperorArthur commented 9 years ago

What's the backtrace from compiling this version?

Also, I've changed a few things, so you're going to need to do that "git fetch -f" over again.

andoruB commented 9 years ago

Here you go: http://pastebin.com/6EsQPdgA I "fetched" the latest revision as you said.

EmperorArthur commented 9 years ago

Ok, much more work has been done. Hopefully this will work for you.

"git pull -f;git checkout master"

gdb ./wxvbam break src/wx/guiinit.cpp:2092 run print anObject next print dialog continue

andoruB commented 9 years ago

http://pastebin.com/cE1zjzRF

EmperorArthur commented 9 years ago

This line caught my eye: "warning: Source file is more recent than executable." That's normally indicative of needing to run "make" to rebuild the executable

Does the program run now? What is the error report if you don't set any breakpoints, and just run the program?

andoruB commented 9 years ago

This line caught my eye: "warning: Source file is more recent than executable." That's normally indicative of needing to run "make" to rebuild the executable

I didn't think I would need to compile the emulator again, so I just updated the code and ran the commands you specified.

Here's the output after making the emu once more: http://pastebin.com/yGQ4aCFr

Does the program run now?

It does, except I get the same error after the emu starts (assert "scrolled" failed), and this time when I open any window from the Options menu, I get greeted with the "can't open user configuration file" error, while this being shown in the terminal:

*\ Caught unhandled unknown exception; terminating

After clicking Ok on the error window, the emulator closes.

What is the error report if you don't set any breakpoints, and just run the program?

Not sure if you mean doing this whithin gdb, but here you go: http://pastebin.com/26R7nNJC

EmperorArthur commented 9 years ago

I've tried to make error handling explain more about the problem. Try compiling with this code.

Also out of curiosity, does it crash when you open Jopypads from the options menu?

I'm trying to figure out what's causing this. It's frustrating because I think it's a wx Version 3 issue, but so far can't replicate it. :/

andoruB commented 9 years ago

I've tried to make error handling explain more about the problem. Try compiling with this code.

Doesn't seem to work properly when using gdb... http://pastebin.com/Tkgk80rK

Also out of curiosity, does it crash when you open Jopypads from the options menu?

Yes, it prints the error with the configuration file, then closes :)

EmperorArthur commented 9 years ago

Did it still print this line, or was it more informative this time?

*\ Caught unhandled unknown exception; terminating

That GDB breakpoint is in a function. Here's an example of what's happening:

function: LoadXRCDialog(...){ ... ... // Breakpoint is right here ... } LoadXRCDialog("GBAROMInfo); LoadXRCDialog("SomeotherDialog"); LoadXRCDialog(...)

If you tell gdb to set a breakpoint it will stop for every function call to that breakpoint. you have to hit continue about ten times and then the program will run.

You actually don't need to worry about setting those breakpoints any more. What I was hoping to see was something like this:

Breakpoint 1, MainFrame::LoadXRCDialog (this=0x87526b0, name=0x8342af1 "GBAROMInfo") next ../src/gtk/scrolwin.cpp(205): assert "scrolled" failed in DoShowScrollbars(): window must be created continue

I'm trying to find what's triggering that assert, and trying to figure out what's causing the program to crash.

andoruB commented 9 years ago

Did it still print this line, or was it more informative this time?

Here's what I've got while running the emulator (not with gdb):

AN ERROR HAS OCCURRED: Pointer of type "P8wxDialog" was not correctly created.

You actually don't need to worry about setting those breakpoints any more. What I was hoping to see was something like this:

Is there something specific I must do to get you the correct error?

EmperorArthur commented 9 years ago

Think of the different parts of a program as books in a library. We call these books "Objects", and give them each a catalog number, just like real books. These catalog numbers are called "Pointers".

What's happening is part of the program is given a pointer, and tries to use it to find an object, just like someone would find a book in a library. The problem is that it was not given a call number, so it doesn't know what to do and the program exits.

That's what "AN ERROR HAS OCCURRED: Pointer of type "P8wxDialog" was not correctly created." means. It's looking for a book ('object') but the program checks to make sure that it wasn't given a bad pointer. It's kind of like looking at a note with a books call number and only seeing a big ZERO written on it. You know that doesn't work.

The hard part is finding out what is passing the note with ZERO on it. Step one was to find out what was taking the note. It's a function called "ShowModal". Now we have to figure out who's passing the bad note to it.

These are all the possibilities, and I will probably end up needing to look through them all:

cd VBA-M/src/wx/ grep --colour -nd recurse -e "ShowModal" . ./gfxviewers.cpp:1045: int ret = dlg.ShowModal(); ./gfxviewers.cpp:1180: if(dlg.ShowModal() == wxID_OK) { ./viewers.cpp:497: int ret = dlg.ShowModal(); ./viewers.cpp:619: int ret = dlg.ShowModal(); ./viewers.cpp:639: if(selregion->ShowModal() != wxID_OK) ./viewers.cpp:655: if(selregion->ShowModal() != wxID_OK) ./viewers.cpp:666: int ret = dlg.ShowModal(); ./viewsupt.cpp:1026: int ret = dlg.ShowModal(); ./panel.cpp:56: dlg.ShowModal(); ./panel.cpp:108: dlg.ShowModal(); ./panel.cpp:171: dlg.ShowModal(); ./cmdevents.cpp:92: if(ShowModal(&dlg) == wxID_OK) ./cmdevents.cpp:592: ShowModal(dlg); ./cmdevents.cpp:621: ShowModal(dlg); ./cmdevents.cpp:635: int ret = ShowModal(&dlg); ./cmdevents.cpp:660: int ret = ShowModal(&dlg); ./cmdevents.cpp:724: int sel = ShowModal(seldlg); ./cmdevents.cpp:757: int ret = ShowModal(&dlg); ./cmdevents.cpp:797: int ret = ShowModal(&dlg); ./cmdevents.cpp:820: int ret = ShowModal(&dlg); ./cmdevents.cpp:832: if(ShowModal(infodlg) != wxID_OK) ./cmdevents.cpp:867: int ret = ShowModal(&dlg); ./cmdevents.cpp:944: int ret = ShowModal(&dlg); ./cmdevents.cpp:1016: int ret = ShowModal(&dlg); ./cmdevents.cpp:1051: int ret = ShowModal(&dlg); ./cmdevents.cpp:1082: int ret = ShowModal(&dlg); ./cmdevents.cpp:1174: ShowModal(dlg); ./cmdevents.cpp:1248: int ret = ShowModal(&dlg); ./cmdevents.cpp:1330: int ret = ShowModal(&dlg); ./cmdevents.cpp:1398: ShowModal(dlg); ./cmdevents.cpp:1404: ShowModal(dlg); ./cmdevents.cpp:1743: if(ShowModal(dlg) == wxID_OK) ./cmdevents.cpp:1775: if(ShowModal(dlg) != wxID_OK) ./cmdevents.cpp:1853: if(ShowModal(dlg) != wxID_OK) ./cmdevents.cpp:1983: if(ShowModal(dlg) != wxID_OK) ./cmdevents.cpp:2068: if(ShowModal(dlg) != wxID_OK) ./cmdevents.cpp:2103: if(ShowModal(dlg) == wxID_OK) ./cmdevents.cpp:2112: if(ShowModal(dlg) == wxID_OK) ./cmdevents.cpp:2124: if(ShowModal(dlg) != wxID_OK) ./cmdevents.cpp:2154: if(ShowModal(dlg) == wxID_OK) ./sys.cpp:477: int ShowModal() {CheckPointer(wxGetApp().frame); return wxGetApp().frame->ShowModal(dlg); } ./sys.cpp:600: int ret = fdlg.ShowModal(); ./sys.cpp:656: psdlg2.ShowModal(); ./sys.cpp:661: psdlg.ShowModal(); ./sys.cpp:667: pmdlg.ShowModal(); ./sys.cpp:788: int ret = dlg.ShowModal(); ./wxvbam.cpp:616:// ShowModal that also disables emulator loop ./wxvbam.cpp:618:int MainFrame::ShowModal(wxDialog dlg) ./wxvbam.cpp:622: int ret = dlg->ShowModal(); ./guiinit.cpp:278: int ret = subdlg.ShowModal(); ./guiinit.cpp:301: int ret = subdlg.ShowModal(); ./guiinit.cpp:321: subdlg->ShowModal(); ./guiinit.cpp:510: if(subdlg->ShowModal() != wxID_OK) ./guiinit.cpp:921: if(subdlg->ShowModal() != wxID_OK) ./wxvbam.h:169: // dialogs, use this function instead of dlg->ShowModal() ./wxvbam.h:170: int ShowModal(wxDialog dlg); ./wxvbam.h:171: // and here are the wrapper functions for use when ShowModal() isn't

EmperorArthur commented 9 years ago

Okay. I just took a look at what pcsx2 does, and am trying that. Run these commands in your build directory

git pull -f git checkout remotes/origin/usewxgtk2 cmake -DCMAKE_BUILD_TYPE=Debug .. make gdb ./wxvbam break src/wx/wxvbam.cpp:620 run print dlg backtrace

Also try running it without gdb and see if it still crashes.

andoruB commented 9 years ago

Oh wow, not getting errors anymore, and the menu options work as intended :D When running the program within gdb, and trying to open a menu entry the program freezes, but I guess that's expected since the program is ran at a specific pointer. Anyway, here's the output: http://pastebin.com/ysxW3bn1

EmperorArthur commented 9 years ago

Since this is working for you I'll go ahead and close this out and create an enhancement issue for using wx 3.0.

andoruB commented 9 years ago

Alright. Thanks for your help and for the patience you had with me in explaining everything :)