Skip to content

cmd/compile: inline of f(m T) from package containing type m causes stack overflow #25984

@dr2chase

Description

@dr2chase

What version of Go are you using (go version)?

Development tip as of bug report (2018-06-20)

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/drchase/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/drchase/GoogleDrive/work/gocode"
GOPROXY=""
GORACE=""
GOROOT="/Users/drchase/GoogleDrive/work/go"
GOTMPDIR=""
GOTOOLDIR="/Users/drchase/GoogleDrive/work/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gr/vvb66dqx6jl6lh8wckfd5p9w0095tn/T/go-build491052553=/tmp/go-build -gno-record-gcc-switches -fno-common"
VGOMODROOT=""

What did you do?

mkdir -p testfoo/src/pkg
cd testfoo
cat > main.go <<"EOF"
package main

import (
"pkg"
"runtime"
)

//go:noinline
func countThreadCreate() int {
n := pkg.ThreadCreateProfile(nil)
return n
}

//go:noinline
func main() {
println("ctc=", countThreadCreate())
n,_ := runtime.ThreadCreateProfile(nil)
println("tcp=", n)
}
EOF
cat > src/pkg/pkg.go <<- "EOF"
package pkg

type m struct {
alllink     *m // Comment out this line for a different error.
}

var allm *m

type StackRecord struct {
Stack0 [32]uintptr
}

func ThreadCreateProfile(m []StackRecord) (n int) {
if mp := allm; mp != nil {
n++
}
return
}
EOF
GOPATH=`pwd` go build main.go

What did you expect to see?

Successful compilation.

What did you see instead?

# command-line-arguments
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow
(etc)

1.10 seems to be okay. This is not caused by the recent CL for importing FOR loops, unless I am utterly failing at "git checkout". I'm still looking for the commit where it goes wrong.

Bad commit is between these two:

Previous HEAD position was 58c231f244 runtime: FreeBSD fast clock_gettime HPET timecounter support
HEAD is now at d2c7dec183 net: implement (*syscall.RawConn).Read/Write on Windows

The good commit is dated "Sat Apr 14 05:36:36 2018 +0000"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions