Skip to content

reflect: unsafe.Pointer used unsafely in reflect.Value #6490

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

Closed
lexprfuncall opened this issue Sep 26, 2013 · 8 comments
Closed

reflect: unsafe.Pointer used unsafely in reflect.Value #6490

lexprfuncall opened this issue Sep 26, 2013 · 8 comments
Milestone

Comments

@lexprfuncall
Copy link

An unsafe pointer typed value is used as both bytes and a pointer in the val member of a
reflect Value structure.  The code knows how to interpret this value correctly based on
a convention of flags stored elsewhere in the value structure.  In essence the code
treats this field as a variant record though the rest of the toolchain has no knowledge
of this convention.

Since there is no variant record concept in Go, the value storage should not conflate
the types of this location.  One possible solution is to split the field storage into
two fields: a uintptr field for non-pointer values and a unsafe.Pointer field for
pointer values.  The same flags can be used to control which field is loaded.
@rsc
Copy link
Contributor

rsc commented Sep 27, 2013

Comment 1:

Labels changed: added priority-later, go1.3, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 2:

Labels changed: added release-go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 3:

Labels changed: removed go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added repo-main.

@bradfitz
Copy link
Contributor

Comment 5:

Is this now entirely fixed by,
https://code.google.com/p/go/source/detail?r=ecccf07e7f
reflect: rewrite Value to separate out pointer vs. nonpointer info.
Needed for precise gc and copying stacks.
reflect.Value now takes 4 words instead of 3.
Still to do:
 - un-iword-ify channel ops.
 - un-iword-ify method receivers.
R=golang-dev, iant, rsc, khr
CC=golang-dev
https://golang.org/cl/43040043
?

Owner changed to @randall77.

Status changed to Started.

@randall77
Copy link
Contributor

Comment 6:

Yes, this bug is mainly fixed by that change.  There are still those pesky still-to-do
notes to make reflect.Value totally gc-clean.

@randall77
Copy link
Contributor

Comment 7:

This issue was updated by revision 2af7a26.

R=rsc
CC=golang-codereviews
https://golang.org/cl/52110044

@randall77
Copy link
Contributor

Comment 8:

This issue was closed by revision 873aaa5.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

5 participants