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
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@aclements
Copy link
Member

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 aclements added release-blocker NeedsFix The path to resolution is known, but the work has not been done. labels Jun 6, 2020
@aclements
Copy link
Member Author

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

@aclements
Copy link
Member Author

@gopherbot, please open backport issues for 1.13 and 1.14

@gopherbot
Copy link

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

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

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.

@golang golang locked and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

2 participants