golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.08k stars 17.68k forks source link

cmd/gc: nosplit stack overflow in long import chain #5094

Closed gopherbot closed 9 years ago

gopherbot commented 11 years ago

by mikaelbrg:

When building my project using "go build" (or "go install"), I get
an error "main.init: nosplit stack overflow":

C:\Users\mikaelbe\work\tigerslam>go build robot
# 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

("┬À1" is displayed like that in the console. I don't know if this is a
hint at where the bug might arise.)

This happened after I moved some code to create more logical and reusable packages. If I
remove all references to the "hectormapping" package, the program will build
successfully. "go build hectormapping" also works.

What steps will reproduce the problem?
1. Build "robot" package: https://bitbucket.org/mikaelbe/tigerslam

What is the expected output?
robot executable

Which compiler are you using (5g, 6g, 8g, gccgo)?
? 

Which operating system are you using?
Windows 7 (x64)

Which version are you using?  (run 'go version')
go version go1.0.3
remyoudompheng commented 11 years ago

Comment 1:

you may work around the issue by flattening your dependency tree: A imports B1 and B2
and B3 and B4 instead of the chain A imports B1 which imports B2 which imports B3 etc.
DanielMorsing commented 11 years ago

Comment 2:

I'm not sure why this check fails. The pkg.init functions aren't marked as nosplit.
alexbrainman commented 11 years ago

Comment 3:

mikaelbrg, I cannot build your package to try it. Please, provide instructions,
including how to set my GOPATH. Thank you.
I think some of your packages use "relative" import paths, and they won't build.
Alex
gopherbot commented 11 years ago

Comment 4 by mikaelbrg:

Alex, I suspect you have problems with one driver package, which refers to a so-file via
cgo. I have now commented out some code, so that the package can be built without this
so-file (see robot/sensors/lidar/driver). This version is tagged "issue5094" in the
repo. I'm sorry i didn't think about this the first time. Apart from that, there
shouldn't be any "magic"; the "robot" and "hectormapping" folders are located in the
same "src" folder at GOPATH.
Further, following suggestions at Stack Overflow
(http://stackoverflow.com/questions/15544601/nosplit-stack-overflow-when-building-go-project),
I have now installed the tip version of Go. I'm happy to report that the tip version
does not have the "nosplit stack overflow" problem!
It may have given me another problem, as it now won't compile with the .so-file
mentioned above ("malformed pe file: unexpected flags for PE section .idata$2"). But
this is likely unrelated to this issue report.
Thank you!
Mikael
alexbrainman commented 11 years ago

Comment 5:

Closing as duplicate.
Your tigerslam/src/robot/main.go imports "robot/controller". Given that your package is
installed (by go get) in my %GOPATH%/src/bitbucket.org/mikaelbe/tigerslam/src/robot, the
import is wrong - it should match the installation path -
"bitbucket.org/mikaelbe/tigerslam/src/robot/controller".
As to your .so file problem, please, create a new issue.
Alex

Status changed to Duplicate.

Merged into issue #4316.