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: -d=checkptr doesn't work with named unsafe.Pointer types #34966

Closed
mdempsky opened this issue Oct 17, 2019 · 1 comment
Closed

cmd/compile: -d=checkptr doesn't work with named unsafe.Pointer types #34966

mdempsky opened this issue Oct 17, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Oct 17, 2019

This package fails to compile with -d=checkptr:

package p

import "unsafe"

type P unsafe.Pointer

func f(p P) *int { return (*int)(p) }
func g(p P) P    { return P(uintptr(p) + 1) }

This is because the runtime functions have unsafe.Pointer parameters, but currently when inserting instrumentation, we pass the unsafe pointers as-is (i.e., as P-typed above, which isn't assignable to unsafe.Pointer).

Fix is to just add appropriate explicit conversions in the instrumentation.

Reported by Asif Jalil on golang-dev.

@mdempsky mdempsky added the NeedsFix label Oct 17, 2019
@mdempsky mdempsky added this to the Go1.14 milestone Oct 17, 2019
@mdempsky mdempsky self-assigned this Oct 17, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 17, 2019

Change https://golang.org/cl/201782 mentions this issue: cmd/compile: fix -d=checkptr for named unsafe.Pointer types

@gopherbot gopherbot closed this in f922645 Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.