SIGBUS is generated generally because of one of two reasons:
- You are trying to access a memory address that doesn’t exist.
- You’re trying to access memory that isn’t aligned on a 4 or 8 byte boundary.
Most likely #1 is the reason given how Corona operates.
Are you using Storyboard or Director? Frequently you will start a timer or have a transition.to execute some onComplete code after a scene has transitioned out of memory and that is a very frequent cause of this.
You could also be calling a function that’s been written over by a variable too. Consider this theoretical scenario:
local function fred()
-- do stuff for function fred
return true
end
fred = 10
-- since "fred" is really just a variable that holds the address of a function, it can be easily overwritten.
-- later on in the code:
someVar = fred()
The program will try to execute the function fred, but the address of fred is no longer were it lived in memory, but is now at memory address 10, which is invalid. The system will generate a signal 10 SIGBUS error and crash.
This is why if you don’t cancel timers, transitions, audio or any thing that is asynchronous that has a call back and executes after that code is removed from memory (i.e. scene change with storyboard) your code goes BOOM.
Corona has no facilities to hep you track them down. The MACH kernal for iOS and OS-X and the Linux kernal for Android are not setup to dump memory cores that you could run a debugger on. The debugging tools like CIDER and CoronaComplete also cannot catch these errors. You just have to hunt for things, and if necessary brute force debug it by commenting out things until the problem goes away.
99% of my SIGBUS and SIGSEGV (signal 11 Segment Violation) errors happen because I missed a call back that fired after I switched scenes in Storyboard or Director . [import]uid: 19626 topic_id: 27643 reply_id: 112207[/import]