Skip to content

runtime: missing stackmap when calling Go function from asm function #39374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erifan opened this issue Jun 3, 2020 · 7 comments
Closed

runtime: missing stackmap when calling Go function from asm function #39374

erifan opened this issue Jun 3, 2020 · 7 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@erifan
Copy link

erifan commented Jun 3, 2020

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

$ go version
tip

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/hostname/.cache/go-build"
GOENV="/home/hostname/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/hostname/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/hostname/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/hostname/go-master"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/hostname/go-master/pkg/tool/linux_arm64"
GCCGO="/usr/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build729455799=/tmp/go-build -gno-record-gcc-switches"

What did you do?

The test case is extracted from gvisor project.
There are three files for the following test case, since the files can't be uploaded on Github, I've posted them all on the page below.
https://play.golang.org/p/kGuVWkQnjwg

Run the test,
$ go test

What did you expect to see?

Test pass

What did you see instead?

runtime: frame asmCallGo/time.muldiv64 untyped locals 0x40027e0e80+0x38
fatal error: missing stackmap

I have also tested this case on linux/amd64 and the same error will occur. Note that the count value in the test is very large, this is set intentionally, and cannot be reproduced when the value is small.

@erifan
Copy link
Author

erifan commented Jun 3, 2020

Stack trace.

runtime stack:
runtime.throw(0x146d6e, 0x10)
        /home/erifan01/go/src/runtime/panic.go:1116 +0x54
runtime.getStackMap(0x4001321bb0, 0x4001321cd8, 0xfac00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/erifan01/go/src/runtime/stack.go:1239 +0x6d8
runtime.scanframeworker(0x4001321bb0, 0x4001321cd8, 0x40000eae98)
        /home/erifan01/go/src/runtime/mgcmark.go:901 +0x54
runtime.scanstack.func1(0x4001321bb0, 0x0, 0x2366a0)
        /home/erifan01/go/src/runtime/mgcmark.go:736 +0x38
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x4006273980, 0x0, 0x0, 0x7fffffff, 0x4001321cc0, 0x0, 0x0, ...)
        /home/erifan01/go/src/runtime/traceback.go:334 +0xd78
runtime.scanstack(0x4006273980, 0x40000eae98)
        /home/erifan01/go/src/runtime/mgcmark.go:739 +0xf4
runtime.markroot.func1()
        /home/erifan01/go/src/runtime/mgcmark.go:226 +0x9c
runtime.markroot(0x40000eae98, 0x271d)
        /home/erifan01/go/src/runtime/mgcmark.go:199 +0x300
runtime.gcDrain(0x40000eae98, 0x3)
        /home/erifan01/go/src/runtime/mgcmark.go:999 +0x10c
runtime.gcBgMarkWorker.func2()
        /home/erifan01/go/src/runtime/mgc.go:1940 +0x70
runtime.systemstack(0x0)
        /home/erifan01/go/src/runtime/asm_arm64.s:237 +0xa0
runtime.mstart()
        /home/erifan01/go/src/runtime/proc.go:1041

@lubinszARM
Copy link

lubinszARM commented Jun 3, 2020

/cc @avagin

@erifan erifan removed their assignment Jun 3, 2020
@erifan
Copy link
Author

erifan commented Jun 3, 2020

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 3, 2020
@dmitshur
Copy link
Member

dmitshur commented Jun 3, 2020

Thanks for the report.

Does this issue reproduce with the latest release? Yes

Do you know if this reproduces with Go 1.13 too?

@cherrymui
Copy link
Member

TEXT ·muldiv64(SB),NOSPLIT,$40-33
// GO_ARGS
FUNCDATA $0, ·muldiv64·args_stackmap(SB)

This function has a non-empty frame, so it needs stack maps. GO_ARGS only covers arguments. You still need a stack map for locals, for which the macro NO_LOCAL_POINTERS will do.

Also, please use the macro GO_ARGS instead of hand-written FUNCDATA.

See https://golang.org/doc/asm for more information.

@shawndx
Copy link
Contributor

shawndx commented Jun 4, 2020

@cherrymui Sorry for commenting a closed issue, just wondering if it's feasible to have 'go vet' check and issue warnings against such usage?

@cherrymui
Copy link
Member

@shawn-xdji I think you can open an issue and let vet maintainers decide. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants