" nosplit堆栈溢出"在构建Go项目时?

时间:2013-03-21 10:12:36

标签: go

我在代码中进行了春季清理,将其拆分为更多Go包,主要是为了帮助重用(每个“building block”在自己的包中)。

修复导入错误后,我发现我的程序突然无法构建。运行“go build”会返回 nosplit堆栈溢出错误。

  

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堆栈溢出

    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

有谁知道这是关于什么的?关于可能导致它的原因,我找不到太多文档,除了在某些情况下这是a bug that supposedly is fixed

部分代码被拆分为“src”文件夹中的新文件夹,因此文件结构现在是:

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

我在Windows 7(x64)上使用Go 1.0.3。

1 个答案:

答案 0 :(得分:6)

这似乎与here描述的相同,据说这是在提示中修复的。可以查看相应的修补程序here

总结一下我所看到的问题: Split stacking用于增长堆栈而不是传统的固定内存区域。这样做的好处是可以生成更多的线程,因为实际上只保留了所需的堆栈内存。这里的问题似乎是链接器标记的函数不会意外地将拆分堆栈上的内存用作'nosplit',因为它找不到拆分堆栈序言。这导致链接器计算错误的堆栈限制,这反过来让链接器认为没有空间并向您抛出错误消息。

可悲的是,获取提示版本的唯一方法是自己编译。正如Nick Craig-Wood已经提到的那样,你可以找到here的说明。如果你真的无法升级,可以尝试通过在init函数中分配一些任意局部变量来解决这个问题。但当然这非常混乱。