dongyi2534 2013-03-21 10:12
浏览 48
已采纳

构建Go项目时出现“未拆分堆栈溢出”?

I did a spring cleaning in my code by splitting it up in more Go packages, mainly to help reusability (each "building block" in its own package).

After fixing the import errors, I discovered that my program suddenly won't build. Running "go build" returns a nosplit stack overflow error.

robot main.init: nosplit stack overflow

    120     guaranteed after split check in main.init
    112     on entry to robot/web.init
    104     on entry to robot/controller.init
    96      on entry to robot/slam.init
    88      on entry to robot/slam/hector.init
    80      on entry to hectormapping/map/mapimages.init
    72      on entry to hectormapping/map/maprep.init
    64      on entry to hectormapping/map/mapproccontainer.init
    56      on entry to hectormapping/scanmatcher.init
    48      on entry to hectormapping/map/gridmap/occbase.init
    40      on entry to hectormapping/map/gridmap/base.init
    32      on entry to hectormapping/map/gridmap.init
    24      on entry to github.com/skelterjohn/go%2ematrix.init
    16      on entry to math.init
    8       on entry to math.init┬À1
    0       on entry to runtime.panicindex
    -8      on entry to runtime.morestack00

runtime.main: nosplit stack overflow

    120     guaranteed after split check in runtime.main
    128     after runtime.main uses -8
    120     on entry to main.init
    112     on entry to robot/web.init
    104     on entry to robot/controller.init
    96      on entry to robot/slam.init
    88      on entry to robot/slam/hector.init
    80      on entry to hectormapping/map/mapimages.init
    72      on entry to hectormapping/map/maprep.init
    64      on entry to hectormapping/map/mapproccontainer.init
    56      on entry to hectormapping/scanmatcher.init
    48      on entry to hectormapping/map/gridmap/occbase.init
    40      on entry to hectormapping/map/gridmap/base.init
    32      on entry to hectormapping/map/gridmap.init
    24      on entry to github.com/skelterjohn/go%2ematrix.init
    16      on entry to math.init
    8       on entry to math.init┬À1
    0       on entry to runtime.panicindex
    -8      on entry to runtime.morestack00

Does anyone know what this is about? I can't find much documentation as to what might be causing it, except that for some cases this is a bug that supposedly is fixed.

Some of the code was split into a new folder in the "src" folder, so that the file structure is now:

src/robot/main.go (main() lives here)
src/robot/(...) (application-specific packages)
src/hectormapping/(...) (stand-alone package used in "robot")

I am using Go 1.0.3 on Windows 7 (x64).

  • 写回答

1条回答 默认 最新

  • douhao7677 2013-03-22 01:11
    关注

    This seems to be the same as described here which was said to be fixed in tip. The corresponding fix can be reviewed here.

    To summarize the problem as I am seeing it: Split stacking is used for growing stacks instead of the conventional fixed memory area. This has the benefit that more threads can be spawned, as only the needed stack memory is actually reserved. The problem here seems to be that the linker marks functions that don't use memory on the split stack accidentally as 'nosplit' because it doesn't find the split stack prologue. This leads to the linker calculating a wrong stack limit, which in turn lets the linker think there's no space and throws the error message at you.

    Sadly, the only way of getting the tip version is to compile it by yourself. As Nick Craig-Wood already mentioned, you can find the instructions here. If you really really can't upgrade, you could try to work around this by allocation some arbitrary local variable in your init functions. But this is very messy of course.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试