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 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。