9

我通过将代码拆分为更多 Go 包对代码进行了大扫除,主要是为了提高可重用性(每个“构建块”都在自己的包中)。

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

机器人 main.init:nosplit 堆栈溢出

    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

有谁知道这是关于什么的?我找不到太多关于可能导致它的文档,除了在某些情况下这是一个据称已修复的错误

部分代码被拆分到“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。

4

1 回答 1

6

这似乎与此处描述的相同,据说是固定在尖端中的。可以在此处查看相应的修复程序。

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

可悲的是,获得尖端版本的唯一方法是自己编译它。正如 Nick Craig-Wood 已经提到的,您可以在此处找到说明。如果您真的无法升级,您可以尝试通过在init函数中分配一些任意局部变量来解决此问题。但这当然很混乱。

于 2013-03-22T01:11:35.570 回答