Skip to content
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

cmd/compile: missing stackmap internal compiler error #22200

Closed
moonheart08 opened this issue Oct 10, 2017 · 11 comments
Closed

cmd/compile: missing stackmap internal compiler error #22200

moonheart08 opened this issue Oct 10, 2017 · 11 comments
Milestone

Comments

@moonheart08
Copy link

Please answer these questions before submitting your issue. Thanks!

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

Go 1.9

Does this issue reproduce with the latest release?

Yes.

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

Arch Linux amd64

What did you do?

It crashed when i added the following to the SRC:
chunk.Voxels[cx][cy][cz] = new(core.HMVoxel)
I cant provide a recipe, but i can make a ZIP of the effected code when i get home.

What did you expect to see?

A successful compilation and/or a compile error

What did you see instead?

An internal compiler error:
# github.com/moonheart08/starlight/worldgen
./algorithms.go:46:2: internal compiler error: missing stack map index for v14 = CALLstatic <mem> {runtime.newobject} [16] v13

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
/usr/lib/go/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xb66f0a, 0x1e, 0xc420471108, 0x1, 0x1)
/usr/lib/go/src/cmd/compile/internal/gc/subr.go:181 +0x230
cmd/compile/internal/gc.(*SSAGenState).Call(0xc42036ea20, 0xc420390620, 0xc4200c6678)
/usr/lib/go/src/cmd/compile/internal/gc/ssa.go:4780 +0x364
cmd/compile/internal/amd64.ssaGenValue(0xc42036ea20, 0xc420390620)
/usr/lib/go/src/cmd/compile/internal/amd64/ssa.go:757 +0x38db
cmd/compile/internal/gc.genssa(0xc42000e3c0, 0xc4203585f0)
/usr/lib/go/src/cmd/compile/internal/gc/ssa.go:4448 +0x2bd
cmd/compile/internal/gc.compileSSA(0xc420374160, 0x0)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:242 +0x7e
cmd/compile/internal/gc.compile(0xc420374160)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:219 +0x218
cmd/compile/internal/gc.funccompile(0xc420374160)
/usr/lib/go/src/cmd/compile/internal/gc/dcl.go:1049 +0xb7
cmd/compile/internal/gc.Main(0xb73f90)
/usr/lib/go/src/cmd/compile/internal/gc/main.go:585 +0x29d2
main.main()
/usr/lib/go/src/cmd/compile/main.go:49 +0x95

@ianlancetaylor ianlancetaylor changed the title Missing stackmap crash cmd/compile: missing stackmap internal compiler error Oct 10, 2017
@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Oct 10, 2017
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 10, 2017
@ianlancetaylor
Copy link
Contributor

Please do give us the source code we need to replicate this ourselves. Thanks.

@moonheart08
Copy link
Author

https://ptpb.pw/lVYL
Uncompressed tar file.

@ianlancetaylor
Copy link
Contributor

Thanks. Your test case does not build for me.

main.go:3:8: cannot find package "github.com/moonheart08/starlight/core" in any of:
	/home/iant/go/src/github.com/moonheart08/starlight/core (from $GOROOT)
	/home/iant/gopath/src/github.com/moonheart08/starlight/core (from $GOPATH)

I tried running go get github.com/moonheart08/starlight/core, but that failed:

# cd .; git clone https://github.com/moonheart08/starlight /home/iant/gopath/src/github.com/moonheart08/starlight
Cloning into '/home/iant/gopath/src/github.com/moonheart08/starlight'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/moonheart08/starlight/core: exit status 128

For this kind of error I doubt it is necessary to include all the dependencies. Can you give us a standalone test case? If that is too hard, we do at least need a test case that we can build ourselves. Thanks.

@moonheart08
Copy link
Author

moonheart08 commented Oct 10, 2017

Oh, sorry. Its set up for my personal folder setup (I have it put in github.com/moonheart08/starlight, its not on github yet)
I have no idea how to make it reproduce, sorry. I can trim out the dependencies, tho. One moment.

@moonheart08
Copy link
Author

This should compile with no dependencies. Also a uncompressed tar file:
https://ptpb.pw/nCmg

@ianlancetaylor
Copy link
Contributor

Thanks. Here is a smaller test case.

package p

type S struct {
	A [64][64][16][16][255]int
}

func F(s S) {
	for _, r1 := range s.A {
		for _, r2 := range r1 {
			for i1, r3 := range r2 {
				for i2, r4 := range r3 {
					for i3 := range r4 {
						r2[i1][i2][i3] = 0
					}
				}
			}
		}
	}
}

@randall77
Copy link
Contributor

This is just a problem with an ICE when the original program is bad.
We should be printing "stack frame too large".
See #20529.
Should be an easy fix. We just have to fail earlier, before we try to generate code for a function with an enormous stack frame.

@moonheart08
Copy link
Author

Just to ask, how would it be recommended to fix the code's stack frame? I kinda need that recursion. (64x64 map of 16x 16y 255z chunks getting a heightmap generated)

@ianlancetaylor
Copy link
Contributor

@moonheart08 An important tip is that for range a where a is an array will make a local copy of a. Especially for a large array, you will often want to write for range &a instead.

@moonheart08
Copy link
Author

moonheart08 commented Oct 11, 2017

@ianlancetaylor Thanks. Thats a little tidbit I didnt know. I always assumed the results of the range (the key and value) were copies.
That explains why the stack is suicidally huge.
Did a quick math. this creates 267386880 new arrays. No wonder.

@gopherbot
Copy link

Change https://golang.org/cl/69810 mentions this issue: cmd/compile: abort earlier if stack frame too large

@randall77 randall77 removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 11, 2017
@golang golang locked and limited conversation to collaborators Oct 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants