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: compiler regression due to deferred call to variadic unsafe-uintptr function #41460

mdempsky opened this issue Sep 17, 2020 · 3 comments


Copy link

@mdempsky mdempsky commented Sep 17, 2020

This used to compile (albeit with possible memory corruption), but now fails to compile with cannot use a0 (type []uintptr) as type uintptr in argument to f:

package p

import "unsafe"

func f(...uintptr) {}

func g(p unsafe.Pointer) {
	defer f(uintptr(p))

Probably due to CL 253457.

I think there are two issues here:

  1. In wrapCall, we need to set the newly created call as a ...-style call if the original one was. (The above code was already rewritten to defer f([]uintptr{uintptr(p)}...) earlier in the compiler.)
  2. wrapCall also needs to look for uintptr(p) conversions within the final []uintptr{...}... argument.

/cc @cuonglm @ianlancetaylor

@mdempsky mdempsky added this to the Go1.16 milestone Sep 17, 2020
@mdempsky mdempsky self-assigned this Sep 17, 2020
Copy link

@cuonglm cuonglm commented Sep 17, 2020

The first issue is quite easy to fix, the second is tricky. Seems we have to convert from slice of uintptr to slice of unsafe.Pointer?


Copy link

@gopherbot gopherbot commented Sep 18, 2020

Change mentions this issue: cmd/compile: more comprehensive tests for #24991


gopherbot pushed a commit that referenced this issue Sep 18, 2020
The revised test now checks that unsafe-uintptr correctly works for
variadic uintptr parameters too, and the CL corrects the code so this
code compiles again.

The pointers are still not kept alive properly. That will be fixed by
a followup CL. But this CL at least allows programs not affected by
that to build again.

Updates #24991.
Updates #41460.

Change-Id: If4c39167b6055e602213fb7522c4f527c43ebda9
Trust: Matthew Dempsky <>
Run-TryBot: Matthew Dempsky <>
Reviewed-by: Cuong Manh Le <>
TryBot-Result: Go Bot <>
Copy link

@gopherbot gopherbot commented Oct 17, 2020

Change mentions this issue: cmd/compile: fix defer/go calls to variadic unsafe-uintptr functions


@gopherbot gopherbot closed this in 76a615b Oct 17, 2020
@golang golang locked and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants