Debugging a strange crash

Hey guys…

I have an app the when reaches a certain point just crashes without any error message other than “AppName stopped working”.

Same thing in the debugger… But if I insert some breakpoints near the crashing situation then it does not crash… SO I can’t find what’s causing the crash…

What seems to make the app crash is the process of selecting a row in a listbox and assigning a variable with some of that listbox cell content and immediately closing tha listbox…

I am now commenting line by line… to try and find the problem… and ideas ?

UPDATE : IF I don’t do a self.close after assigning the value to the variable… the crash seems to go away…

UPDATE2: The problem is somehow related the code in the close event in the window that holds the listbox

Make sure when you run this in the debugger you have “break on exceptions” enabled
Unless its a hard crash (not an exception) this should stop on the code that is causing the problem
I almost never run without this on

A hard crash (where the app just exits) is much harder to catch or diagnose

Hey Norman, “break on exceptions” It IS on…

I’m still scratching my head… Deleted all the code in the close event of the window that holds the ListBox and still crashes…

hard crash ?
never stops in the debugger ?

that certainly suggests the issue is something else

cant guess from here what that might be though

Yep, hard crash, no stopping in the debugger…

I couldn’t find the problem… I had to put a button to close the window manually instead of closing it right after the selection was done in the listbox…

One trick I use to debug hard crashes is to go step by step through a method (put the breakpoint at the top) - the app will not crash until you get to the line that’s doing so.

Tim, what’s funny about this crash in particular is that if I do what you suggest it won’t crash!

sometimes simply sprinkle system,debuglog’s all around where you suspect things are going wrong helps
you have to watch this using either console on OS X or debugview on WIndows

BUT since if you debug it does NOT do this suggests very strongly you have an event order or event timing bug

Put the breakpoint at the top of the close method.

No, Tim… as soon as I break into the debugger the bug is gone…

I’ve done something like this already.

Sub Debug(Text as String) DebugLabel.Text = Text DebugLabel.Refresh End Sub

Then put a Debug("MethodName") in every method or event being called. Once you find out what method the crash is occurring in you can put a debug before every line of code.

It could be related to this? feedback://showreport?report_id=46569

Hey Neil… Hmm… intresting. It might be related to feedback://showreport?report_id=46569 as the beahavior is similiar…

thanks for pointing me out the bug… trying out a workaround with a timer now… (as the feedback suggests)

UPDATE: until now, using a timer to close the window made the crash go away…

Maybe try this.

Xojo.Core.Timer.CallLater(1,AddressOf myWindow.close)

It avoids the crash - but doesn’t “fix” the crash

This really tells me its an event order bug in your code

I used “go away” because didn’t test it much.
Not sure how can I fix the crash.
Can anyone enlighten me on how to detect/recognize event order bugs. ?
Thanks

They’re hard to track down and often manifest themselves as “crashes/gets exceptions when built & but not in debug”
Often what I end up doing is resorting to inserting System.Debuglog where I suspect and then running and watching Console on OS X (or DebugView on Windows)
Its whats affectionately known as “printf debugging” :slight_smile: