Navigation Menu

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
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@randall77
Copy link
Contributor

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

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

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 23, 2020
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest 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

3 participants