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

runtime, cmd/compile: implicit allocations allowed in the runtime #42158

Open
randall77 opened this issue Oct 22, 2020 · 1 comment
Open

runtime, cmd/compile: implicit allocations allowed in the runtime #42158

randall77 opened this issue Oct 22, 2020 · 1 comment

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Oct 22, 2020

We have a test in the compiler that ensures that we don't have any implicit allocations in the runtime. We want all allocations that the runtime does to be explicit (to avoid things like self-deadlock when allocating inside malloc).
That test doesn't catch all the allocations. In particular, it doesn't catch the allocation required to assign non-pointer types to interfaces. There may be others, I haven't checked.

I hacked a simple test into the compiler, and found a bunch of situations where this implicit allocation happens. An example:

func goPanicIndex(x int, y int) {
	panicCheck1(getcallerpc(), "index out of range")
	panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex})
}

This code needs to allocate a boundsError and put its address in the data field of an interface.
All current missed interface-conversion allocations are of this form (an argument to panic).

I ran into this issue in a CL I'm working on where implicit allocations were happening in a bad place, and it took me a while to track it down. It would have been much easier for the compiler to give me an error.

Update #42076

@josharian

@randall77 randall77 added this to the Unplanned milestone Oct 22, 2020
@randall77
Copy link
Contributor Author

@randall77 randall77 commented Oct 22, 2020

p.s. The panicCheck1 call ensures we can malloc (and throws instead if we can't).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.