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

Fix cycle detection in internal/value.Format #87

Merged
merged 1 commit into from
Mar 28, 2018
Merged

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Mar 28, 2018

The cycle detection in value.Format uses a map of uintptrs, which is not
correct as this assumes that the Go GC never uses a moving collector.
Instead, we should be using unsafe.Pointer, which the GC knows how to scan.

Also, push pointer checking of slices down to the level of individual elements.
We do this because the slice pointer is not sufficient to determine equality.
For example, v[:0] and v[:1] both have the same slice pointer, but are
clearly different values.

Since the purego environment forbids the use of unsafe, create a Pointer type
that is an abstraction over an opaque pointer. The Pointer type can only be
compared. In the purego, continue to use uintptr, which is the best we can do.

The cycle detection in value.Format uses a map of uintptrs, which is not
correct as this assumes that the Go GC never uses a moving collector.
Instead, we should be using unsafe.Pointer, which the GC knows how to scan.

Also, push pointer checking of slices down to the level of individual elements.
We do this because the slice pointer is not sufficient to determine equality.
For example, v[:0] and v[:1] both have the same slice pointer, but are
clearly different values.

Since the purego environment forbids the use of unsafe, create a Pointer type
that is an abstraction over an opaque pointer. The Pointer type can only be
compared. In the purego, continue to use uintptr, which is the best we can do.
@dsnet dsnet merged commit 5411ab9 into master Mar 28, 2018
@dsnet dsnet deleted the format-cycles branch March 28, 2018 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant