Simulator crashes

Corona Simulator started crashing on me for some reason. In what now appear to me to be identical circumstances in my app it sometimes crashes, sometimes it does not. I didn’t change anything major when this started happening, and a previous build does not crash.

I was trying to use apple’s Instruments profiler on my app running on my iPhone, but after I couldn’t get the iPhone or it’s processes to show up, I went ahead and pointed the profiler to Corona Simulator just to see if it would work. After some time debugging, the app started crashing when I inserted some "print"s. I removed them, but the crash persisted, in a very reproducible way. After a reboot the same set of actions did not lead to a crash.

Now, the application sometimes crashes after that same set of actions, and sometimes it doesn’t.

I’m getting this message in the console:

/Applications/CoronaSDK/Corona Terminal: line 9: 252 Bus error “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
logout

[Process completed]
The profiler reported 14k worth of memory leaks, so if that information is about my app and not the simulator, memory leaks shouldn’t be the problem.

Any clues to what might be the problem? Is there anything I can do to help pinpoint the problem? [import]uid: 8145 topic_id: 2986 reply_id: 302986[/import]

I think I found the error on my part.

I was removing my scene when switching levels, and then GC’ing. I had to insert my character after remembering the scene width/height, due to my character having swappable clothes and this bug, which made the scene width/height bogus and wouldn’t let me scroll it properly: https://developer.anscamobile.com/forum/2010/09/22/improper-width-groups-have-empty-groups-children

My map scrollers have a reference to a group that never changes - the scene, to which I insert all components of my levels.

Apparently, though, the character was part of the level I was trying to clean, and only stopped being a part of it when I added him to my new level after remembering the scene width/height. So when I cleaned the last level, the character must have gotten cleaned along with them, and was sometimes GC’ed, which caused the crashed.

The extra functions I wrote must have tipped over some line where the GC calls became nearly-instant most of the time, or something.

I think it’s a bug the simulator crashes, though not a very significant one. Sorry for posting sort of prematurely, these crashes were a real surprise and after an hour of debugging with them, I ran out of ideas on how to pinpoint them for a while. [import]uid: 8145 topic_id: 2986 reply_id: 8598[/import]

Posting this here, due to being unable to edit the original post. I fixed the issue, though the simulator crashing is sort of a bug, this was more an error on my part than a serious issue. I left the symptoms here if anyone has the same thing before the bug is fixed. Bottom line - be more careful about not referencing things that could have been GC’ed =)
I’m also getting a 513, 531, 546, 561 Bus error… Seems to be different every time. The time to crash is also very different, but always happens on a rather memory intensive operation that has garbage collect calls.

Edit: I discovered that commenting the GC calls out appears to make the crashes unreproducible, so GC might be the problem. I believe I was quite careful about not referencing anything that is GC’ed, so I hope it’s not from obviously incorrect usage of the mechanism. I’ll look into this very closely on my side, and will try to reproduce this in a simple case.

The odd thing is, these started appearing very, very frequently when I was debugging an almost completely unrelated module to the places where the GC calls are.

I was working on my character functions that analyze arrays and decide what place the character should go to on certain user input, and mostly was changing cycles, refactoring code to separate functions, adding some debug prints, but nothing major that has anything to do with allocating and deallocating memory. In fact, when the errors started happening I commented out the only call to the function that calls all the changes I made, and nothing changed in respect to the crashes. [import]uid: 8145 topic_id: 2986 reply_id: 8595[/import]