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: missing page mark in write barrier #39432

Closed
aclements opened this issue Jun 6, 2020 · 7 comments
Closed

runtime: missing page mark in write barrier #39432

aclements opened this issue Jun 6, 2020 · 7 comments
Assignees
Milestone

Comments

@aclements
Copy link
Member

@aclements aclements commented Jun 6, 2020

There are two places in the runtime where we set mark bits: greyobject and wbBufFlush1. The page sweeper depends on page marks being set whenever any object in a span is marked, but we currently only set page marks in greyobject. This means if all of the reachable objects on a span are marked by the write barrier, the page mark for the span won't be set, and the page sweeper will incorrectly reclaim the span. This is fairly unlikely, but possible, especially if very few objects in a span are actually live.

I found this by chance when I was reorganizing these two functions. I'm fairly certainly this has been a bug since page marks were introduced in Go 1.12.

/cc @mknyszek

@aclements
Copy link
Member Author

@aclements aclements commented Jun 6, 2020

Actually, we're also missing the page mark in gcmarknewobject.

@aclements
Copy link
Member Author

@aclements aclements commented Jun 6, 2020

@gopherbot, please open backport issues for 1.13 and 1.14

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 6, 2020

Backport issue(s) opened: #39433 (for 1.13), #39434 (for 1.14).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 6, 2020

Change https://golang.org/cl/236817 mentions this issue: runtime: always mark span when marking an object

@gopherbot gopherbot closed this in 886caba Jun 8, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 8, 2020

Change https://golang.org/cl/236922 mentions this issue: [release-branch.go1.14] runtime: always mark span when marking an object

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 8, 2020

Change https://golang.org/cl/236923 mentions this issue: [release-branch.go1.13] runtime: always mark span when marking an object

@aclements
Copy link
Member Author

@aclements aclements commented Jun 11, 2020

Ah! I was wrong. This is a performance bug, but not in fact a correctness bug.

The page sweeper uses the span marks to determine where it thinks sweeping will return whole spans, but it just calls sweep, and sweep will do the appropriate thing for any span. Hence, the span marks are really just a hint (albeit an important one for the performance of the sweeper). Since we already mostly got the span marks right, I don't think the performance bug here is severe, and hence not worth the backports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.