Bus Errors: Corona Bug or Error in Code

I am currently getting this error and corona crashes:

/Users/myMac/Desktop/CoronaSDK/Corona Terminal: line 9: 27835 Bus error: 10 "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $\*

Is this a bug with Corona or is there an error in my code? [import]uid: 54716 topic_id: 15633 reply_id: 315633[/import]

Here’s a great post relating to bus error, why it happens and how you might be able to go about fixing it:

http://developer.anscamobile.com/forum/2011/05/26/bus-error

Good luck! [import]uid: 67217 topic_id: 15633 reply_id: 57704[/import]

Not a Corona bug, but likely an error in your code - are you using physics? [import]uid: 52491 topic_id: 15633 reply_id: 57742[/import]

Does it happen under certain situations? Like on removal of physical bodies ? [import]uid: 84637 topic_id: 15633 reply_id: 57802[/import]

The first time it happened was after leaving a scene that had physics with director, so it would have made sense. I would have assumed it had something to do with the physics. But after that it started occurring when on scene that does not have physics(and no physics up to that point). The scene that it crashes on only has transitions and timers. It doesn’t happen every time but it is very worrisome. [import]uid: 54716 topic_id: 15633 reply_id: 57817[/import]

Are you canceling your active transitons/timers before changing scenes? [import]uid: 84637 topic_id: 15633 reply_id: 57845[/import]

Yeah, I actually created a director wrapper that candles all transitions and timers. I can post the code and the mac crash report. Just let me know what is the best way to post it.

Thanks [import]uid: 54716 topic_id: 15633 reply_id: 57879[/import]

Okay this is getting really frustrating. I am putting the app on my phone, and it crashes or restarts the app on that same screen. [import]uid: 54716 topic_id: 15633 reply_id: 57884[/import]

This is ridiculous. Why doesn’t this code work??? It crashes during playFirst on my phone and crashes Corona randomly on all scenes. The other ones rarely work when they want to. What is going on? And I am not getting any errors from Corona or Director.

[lua]module( …,package.seeall )

– LOCAL VARIABLES

local deviceWidth = display.contentWidth
local deviceHeight = display.contentHeight
local centered = {x = deviceWidth * 0.5, y = deviceHeight * 0.5}
local localTransitions = {}
local localTimers = {}
local myParams = {}


– MAIN GROUP

local sceneGroup = display.newGroup()

function delaySkip()
function sceneGroup:tap( event )
scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers)
end
sceneGroup:addEventListener(“tap”, sceneGroup)
end
localTimers[“delaySkip1”] = timer.performWithDelay(1000, delaySkip)


– ANIMATE FUNCTIONS


– SCENES


– SCENE ONE

local function playFirst()
sceneGroup:removeEventListener(“tap”, sceneGroup)
function delaySkip()
function sceneGroup:tap( event )
scenes:changeScene(“playScreen”, “fade”, params, localTransitions, localTimers)
end
sceneGroup:addEventListener(“tap”, sceneGroup)
end
localTimers[“delaySkip1”] = timer.performWithDelay(1000, delaySkip)

local scene = display.newGroup()
sceneGroup:insert(scene)

local bg1 = display.newImage(“scene1_1a.png”, true)
sceneGroup:insert(bg1)
bg1.x, bg1.y = centered.x, centered.y

local bg2, bg3, bg4, bg5 = nil
local function transition1()
bg2 = display.newImage(“scene1_1b.png”, true)
sceneGroup:insert(bg2)
bg2.x, bg2.y = centered.x, centered.y

end

local function transition2()
bg3 = display.newImage(“scene1_2.png”, true)
sceneGroup:insert(bg3)
bg3.x, bg3.y = centered.x, centered.y

end

local function transition3()
bg4 = display.newImageRect(“scene5_4.jpg”, 480, 320)
scene:insert(bg4)
bg4.x, bg4.y = centered.x, centered.y
bg4.alpha = 0

localTransitions[“scene5_4a”] = transition.to(bg3, {time = 500, alpha = 0})
localTransitions[“scene5_4b”] = transition.to(bg4, {time = 500, alpha = 1, onComplete = function() bg3:removeSelf() end})
end

local function transition4()
localTransitions[“scene5_5”] = transition.to(bg4, {time = 500, alpha = 0, onComplete = function() bg4:removeSelf() end})
end

local function transition5()
bg5 = display.newGroup()
scene:insert(bg5)
bg5.alpha = 0

local s1 = display.newImageRect(“scene5_5_01.png”, 480, 349)
bg5:insert(s1)
s1.x, s1.y = centered.x, centered.y

local s2 = display.newImageRect(“scene5_5_02.png”, 480, 439)
bg5:insert(s2)
s2.x, s2.y = centered.x, s1.y + s2.height * 0.895

local s3 = display.newImageRect(“scene5_5_03.png”, 480, 393)
bg5:insert(s3)
s3.x, s3.y = centered.x, s2.y + 416

localTransitions[“scene5_6”] = transition.to(bg5, {time = 500, alpha = 1})
end

local function transition6()
localTransitions[“scene5_5”] = transition.to(bg5, {time = 5000, y = -bg5.height * 0.7125})
end

local function transition7()
bg6 = display.newImageRect(“thend.png”, 320, 480)
scene:insert(bg6)
bg6.x, bg6.y = centered.x, centered.y
bg6.alpha = 0

localTransitions[“scene5_fine”] = transition.to(bg6, {time = 500, alpha = 1})
end


– SCENE FOUR PLAY

localTimers[“scene5_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene5_2”] = timer.performWithDelay(3500, transition2)
–localTimers[“scene5_3”] = timer.performWithDelay(5000, transition3)
–localTimers[“scene5_4”] = timer.performWithDelay(6500, transition4)
–localTimers[“scene5_5”] = timer.performWithDelay(9000, transition5)
–localTimers[“scene5_6”] = timer.performWithDelay(11000, transition6)
–localTimers[“scene5_7”] = timer.performWithDelay(12000, transition7)

end


– SCENE TWO

local function playSecond()
print(“PLaying Second Clip”)
local scene = display.newGroup()
sceneGroup:insert(scene)

local bg1 = display.newImageRect(“scene2_1.jpg”, 480, 320)
scene:insert(bg1)
bg1.x, bg1.y = centered.x, centered.y
bg1.alpha = 1

local bg2, bg3 = nil
local function transition1()
localTransitions[“scene2_1”] = transition.to(bg1, {time = 500, alpha = 0})
end

–raining
local function transition2()
bg2 = display.newGroup()
scene:insert(bg2)
bg2.alpha = 0

local bg2a = display.newImageRect(“scene2_2.jpg”, 480, 320)
bg2:insert(bg2a)
bg2a.x, bg2a.y = centered.x, centered.y

local function rain()
local rain1 = display.newImageRect(“scene2_2screen.png”, 480, 320)
bg2:insert(rain1)
rain1.x, rain1.y = centered.x, centered.y
rain1.alpha = .3

end
rain()
localTransitions[“scene2_2”] = transition.to(bg2, {time = 500, alpha = 1, onComplete = function() bg1:removeSelf() end})
end

local function transition3()
localTransitions[“scene2_2”] = transition.to(bg2, {time = 500, alpha = 0, onComplete = function() bg2:removeSelf() end})
end

local function transition4()
bg3 = display.newImageRect(“scene2_3.jpg”, 480, 320)
scene:insert(bg3)
bg3.x, bg3.y = centered.x, centered.y
bg3.alpha = 0

localTransitions[“scene2_3”] = transition.to(bg3, {time = 500, alpha = 1})
end

local function transition5()
localTransitions[“scene2_fine”] = transition.to(bg3, {time = 500, alpha =0, onComplete = function() bg3:removeSelf(); scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers) end })
end


– SCENE TWO PLAY

localTimers[“scene2_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene2_2”] = timer.performWithDelay(3000, transition2)
localTimers[“scene2_3”] = timer.performWithDelay(8000, transition3)
localTimers[“scene2_4”] = timer.performWithDelay(8000, transition4)
localTimers[“scene2_fine”] = timer.performWithDelay(12000, transition5)
end


– SCENE THREE

local function playThird()
local scene = display.newGroup()
sceneGroup:insert(scene)

local bg1 = display.newImageRect(“scene3_1.jpg”, 806, 320)
scene:insert(bg1)
bg1.x, bg1.y = centered.x + bg1.width * 0.2, centered.y

local bg2, bg3, bg4 = nil
local function transition1()
localTransitions[“scene3_1”] = transition.to(bg1, {time = 1000, x = centered.x - bg1.width * 0.2})
end

local function transition2()
bg2 = display.newImageRect(“scene3_2.jpg”, 806, 320)
bg2.x, bg2.y = bg1.x, bg1.y
end

local function transition3()
localTransitions[“scene3_1b”] = transition.to(bg2, {time = 1000, x = centered.x + bg2.width * 0.2, onComplete = function() bg1:removeSelf() end})
end

local function transition4()
localTransitions[“scene3_fine”] = transition.to(bg2, {time = 500, alpha =0, onComplete = function() bg2:removeSelf(); scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers) end })
end

– SCENE THREE PLAY

localTimers[“scene3_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene3_1a”] = timer.performWithDelay(4500, transition2)
localTimers[“scene3_1b”] = timer.performWithDelay(6000, transition3)
localTimers[“scene3_fine”] = timer.performWithDelay(9000, transition4)

end


– SCENE FOUR

local function playFourth()
local scene = display.newGroup()
sceneGroup:insert(scene)

local bg1 = display.newImage(“scene4_1.jpg”, true)
scene:insert(bg1)
bg1.x, bg1.y = 545, centered.y

local function transition1()
localTransitions[“scene4_1”] = transition.to(bg1, {time = 2500, x = -55})
end
–[[
local function transition2()
localTransitions[“scene4_1b”] = transition.to(bg1, {time = 1000, x = 100, xScale =.7, yScale = .7})
end
]]–

local function transition4()
localTransitions[“scene4_fine”] = transition.to(bg1, {time = 500, alpha =0, onComplete = function() bg1:removeSelf(); scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers) end })
end

– SCENE FOUR PLAY

localTimers[“scene4_1a”] = timer.performWithDelay(2000, transition1)
localTimers[“scene4_fine”] = timer.performWithDelay(7000, transition4)
–[[
localTimers[“scene4_1b”] = timer.performWithDelay(7000, transition2)
localTimers[“scene4_1c”] = timer.performWithDelay(6000, transition3)
]]–
end


– SCENE FIFTH

local function playFifth()
sceneGroup:removeEventListener(“tap”, sceneGroup)
function delaySkip()
function sceneGroup:tap( event )
scenes:changeScene(“playScreen”, “fade”, params, localTransitions, localTimers)
end
sceneGroup:addEventListener(“tap”, sceneGroup)
end
localTimers[“delaySkip1”] = timer.performWithDelay(1000, delaySkip)

local scene = display.newGroup()
sceneGroup:insert(scene)

local bg1 = display.newImage(“scene5_1.jpg”, true)
scene:insert(bg1)
bg1.x, bg1.y = centered.x, centered.y

local bg2, bg3, bg4, bg5 = nil
local function transition1()
bg2 = display.newImageRect(“scene5_2.jpg”, 480, 320)
scene:insert(bg2)
bg2.x, bg2.y = centered.x, centered.y
bg2.alpha = 0

localTransitions[“scene5_2a”] = transition.to(bg1, {time = 500, alpha = 0})
localTransitions[“scene5_2b”] = transition.to(bg2, {time = 500, alpha = 1, onComplete = function() bg1:removeSelf() end})
end

local function transition2()
bg3 = display.newImageRect(“scene5_3.jpg”, 480, 320)
scene:insert(bg3)
bg3.x, bg3.y = centered.x, centered.y
bg3.alpha = 0

localTransitions[“scene5_3a”] = transition.to(bg2, {time = 500, alpha = 0})
localTransitions[“scene5_3b”] = transition.to(bg3, {time = 500, alpha = 1, onComplete = function() bg2:removeSelf() end})
end

local function transition3()
bg4 = display.newImageRect(“scene5_4.jpg”, 480, 320)
scene:insert(bg4)
bg4.x, bg4.y = centered.x, centered.y
bg4.alpha = 0

localTransitions[“scene5_4a”] = transition.to(bg3, {time = 500, alpha = 0})
localTransitions[“scene5_4b”] = transition.to(bg4, {time = 500, alpha = 1, onComplete = function() bg3:removeSelf() end})
end

local function transition4()
localTransitions[“scene5_5”] = transition.to(bg4, {time = 500, alpha = 0, onComplete = function() bg4:removeSelf() end})
end

local function transition5()
bg5 = display.newGroup()
scene:insert(bg5)
bg5.alpha = 0

local s1 = display.newImageRect(“scene5_5_01.png”, 480, 349)
bg5:insert(s1)
s1.x, s1.y = centered.x, centered.y

local s2 = display.newImageRect(“scene5_5_02.png”, 480, 439)
bg5:insert(s2)
s2.x, s2.y = centered.x, s1.y + s2.height * 0.895

local s3 = display.newImageRect(“scene5_5_03.png”, 480, 393)
bg5:insert(s3)
s3.x, s3.y = centered.x, s2.y + 416

localTransitions[“scene5_6”] = transition.to(bg5, {time = 500, alpha = 1})
end

local function transition6()
localTransitions[“scene5_5”] = transition.to(bg5, {time = 5000, y = -bg5.height * 0.7125})
end

local function transition7()
bg6 = display.newImageRect(“thend.png”, 320, 480)
scene:insert(bg6)
bg6.x, bg6.y = centered.x, centered.y
bg6.alpha = 0

localTransitions[“scene5_fine”] = transition.to(bg6, {time = 500, alpha = 1})
end


– SCENE FOUR PLAY

localTimers[“scene5_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene5_2”] = timer.performWithDelay(3500, transition2)
localTimers[“scene5_3”] = timer.performWithDelay(5000, transition3)
localTimers[“scene5_4”] = timer.performWithDelay(6500, transition4)
localTimers[“scene5_5”] = timer.performWithDelay(9000, transition5)
localTimers[“scene5_6”] = timer.performWithDelay(11000, transition6)
–localTimers[“scene5_7”] = timer.performWithDelay(12000, transition7)

end

– GET STORYBOARD

local function storyboard( w )
if w == 1 then playFirst()
elseif w == 2 then playSecond()
elseif w == 3 then playThird()
elseif w == 4 then playFourth()
elseif w == 5 then playFifth()
end
end

– NEW FUNCTION

new = function( params )
myParams = params or nil
storyboard(myParams.world)
return sceneGroup
end[/lua]

Edit:: I noticed that I get this:

 Invalid memory access of location 0x0 eip=0x0

Before my bus error and the game continues to crash when reopening corona.
[import]uid: 54716 topic_id: 15633 reply_id: 57908[/import]

Someone ever solved a bus error ?
" exited abnormally with signal 10: Bus error active (but IDLE) sessions
"
[import]uid: 69481 topic_id: 15633 reply_id: 82220[/import]

No sorry. I ended up rewriting the whole thing and redoing all my images. [import]uid: 54716 topic_id: 15633 reply_id: 83225[/import]

Another reason for a bus error:

Just a note for all those newbies out there just like me. There is another way to have a bus error!

I just finished my first corona app, and although it ran fine in the simulator, when i attempted to build it for iOS, it crashed the simulator during the build process and gave a “line 9: bus error”.
After much frustration, I found out that i had an extra closing curly brace “}”, following “plist” in the build.settings file. Removing this brace allowed the app to build just fine! [import]uid: 125649 topic_id: 15633 reply_id: 101436[/import]

For me, this error is always the result of too-aggressively disposing sprite sheets, and then trying to access a reference later.

[import]uid: 105599 topic_id: 15633 reply_id: 119786[/import]

For me, this error is always the result of too-aggressively disposing sprite sheets, and then trying to access a reference later.

[import]uid: 105599 topic_id: 15633 reply_id: 119786[/import]