【问题标题】:Corona SDK Application exited abnormally with signal 10: Bus Error: 10. Device CrashCorona SDK 应用程序异常退出,信号 10:总线错误:10。设备崩溃
【发布时间】:2014-04-28 13:48:24
【问题描述】:

我有一个在 Corona 模拟器中运行良好的应用程序,但在设备本身上崩溃,并且它在 iOS 设备控制台中返回以下错误:

Mar 20 22:56:26 tmacs-iPhone backboardd[28] <Warning>: Application 'UIKitApplication:HappyShaker[0x9cf9]' exited abnormally with signal 10: Bus error: 10
Mar 20 22:56:26 tmacs-iPhone backboardd[28] <Warning>: BKSendGSEvent ERROR sending event type 23: (ipc/send) invalid destination port (0x10000003)

根据我的研究,我发现这个错误是由以下两个问题引起的:

  1. 访问不存在的内存
  2. 访问未在 4 或 8 字节边界上对齐的内存

根据 Corona 的运作方式,这很可能是第一个原因。

在调试时,我发现了一些缩小问题搜索范围的方法。

下面的这段代码会导致应用程序崩溃。它是一个按钮,用于启动物理、设置其比例、添加物理对象、启动计时器,并在按下按钮后移除按钮。它有点初始化物理。

local playButton = nil
local function handleButtonEvent( event )
    if "ended" == event.phase then
        physics.start()
        physics.setScale(60)
        physics.addBody( red, "dynamic",redBody )
        physics.addBody( borderTop, "static", borderBodyElement )
        physics.addBody( borderBottom, "static", borderBodyElement )
        physics.addBody( borderLeft, "static", borderBodyElement )
        physics.addBody( borderRight, "static", borderBodyElement )
        timer.performWithDelay(1000, fn_counter, number)
        playButton:removeSelf()
        playButton = nil
    end
    return true
end
playButton = widget.newButton {
    left = _W/2-53,
    top = 400,
    width = 105,
    height = 39,
    defaultFile = "start.png",
    overFile = "start_pressed.png",
    label = "",
    onEvent = handleButtonEvent,
}
playButton.isActive = true
group:insert(playButton)

当我注释掉代码的按钮小部件部分时,它可以正常工作并且不会崩溃。注释掉的部分在下面的代码中有说明。

    -- local playButton = nil
 --     local function handleButtonEvent( event )
    --  if "ended" == event.phase then
            physics.start()
            physics.setScale(60)
            physics.addBody( red, "dynamic",redBody )
            physics.addBody( borderTop, "static", borderBodyElement )
            physics.addBody( borderBottom, "static", borderBodyElement )
            physics.addBody( borderLeft, "static", borderBodyElement )
            physics.addBody( borderRight, "static", borderBodyElement )
            timer.performWithDelay(1000, fn_counter, number)
    --      playButton:removeSelf()
    --      playButton = nil
    --  end
    --  return true
    -- end
    -- playButton = widget.newButton {
    --  left = _W/2-53,
    --  top = 400,
    --  width = 105,
    --  height = 39,
    --  defaultFile = "start.png",
    --  overFile = "start_pressed.png",
    --  label = "",
    --  onEvent = handleButtonEvent,
    -- }
    -- playButton.isActive = true
    -- group:insert(playButton) 

以前有人在使用按钮小部件时遇到过这个问题吗?

我还应该提到,这段代码位于情节提要的 createScene() 函数中。

【问题讨论】:

    标签: ios mobile lua segmentation-fault coronasdk


    【解决方案1】:

    我找到了解决方案。它与 Physics.start() 位于侦听器函数内部有关。我做了以下调整:

    physics.start()
    physics.setScale( 60 )
    physics.addBody( borderTop, "static", borderBodyElement )
    physics.addBody( borderBottom, "static", borderBodyElement )
    physics.addBody( borderLeft, "static", borderBodyElement )
    physics.addBody( borderRight, "static", borderBodyElement )
    
    -- local startButton = nil
    local function handleButtonEvent( event )
        if "ended" == event.phase then
    
            physics.addBody( red, "dynamic",redBody )
            timer.performWithDelay(1000, fn_counter, number)
            startButton:removeSelf()
            startButton = nil
        end
        return true
    end
    

    通过将physics.start() 函数放在侦听器事件函数之外使其工作。但是,我仍然对为什么这会导致分段错误感到困惑。谁能给我解释一下?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-17
      相关资源
      最近更新 更多