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 a race between forwarding bits and VO bits. #1214

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

wks
Copy link
Collaborator

@wks wks commented Oct 11, 2024

The current code sets the forwarding bits before setting the VO bit when copying an object. If another GC worker is attempting to forward the same object, it may observe the forwarding bits being FORWARDED but the VO bit is not set. This violates the semantics of VO bits because VO bits should be set for both from-space and to-space copies. This will affect VM bindings that assert slots always refer to a valid object when scanning objects and may update the same slot multiple times for some reasons.

This revision provides a mechanism to ensure that all necessary metadata are set before setting forwarding bits to FORWARDED. Currently it affects the VO bits and the mark bits (which are used to update the VO bits in Immix-based plans). It may be used for other metadata introduced in the future.

@wks wks requested review from qinsoon, k-sareen and tianleq October 11, 2024 03:36
Copy link
Member

@qinsoon qinsoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qinsoon
Copy link
Member

qinsoon commented Oct 11, 2024

error: cannot install package `cargo-msrv 0.16.2`, it requires rustc 1.78 or newer, while the currently active rustc version is 1.77.0
`cargo-msrv 0.1[6](https://github.com/mmtk/mmtk-core/actions/runs/11285882886/job/31389361498?pr=1214#step:5:7).0` supports rustc 1.76

Maybe we should pin to a specific cargo-msrv version before we bump our Rust toolchain version.

Copy link
Collaborator

@tianleq tianleq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@k-sareen k-sareen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

The current code sets the forwarding bits before setting the VO bit when
copying an object.  If another GC worker is attempting to forward the
same object, it may observe the forwarding bits being `FORWARDED` but
the VO bit is not set.  This violates the semantics of VO bits because
VO bits should be set for both from-space and to-space copies.  This
will affect VM bindings that assert slots always refer to a valid object
when scanning objects and may update the same slot multiple times for
some reasons.

This revision provides a mechanism to ensure that all necessary metadata
are set before setting forwarding bits to `FORWARDED`.  Currently it
affects the VO bits and the mark bits (which are used to update the VO
bits in Immix-based plans).  It may be used for other metadata
introduced in the future.
@wks wks force-pushed the fix/forwarded-race branch from 48ac048 to 3b04648 Compare October 11, 2024 07:07
@wks wks enabled auto-merge October 11, 2024 07:08
@wks wks added this pull request to the merge queue Oct 11, 2024
Merged via the queue into mmtk:master with commit 328deb6 Oct 11, 2024
33 checks passed
@wks wks deleted the fix/forwarded-race branch October 11, 2024 09:09
wks added a commit to wks/mmtk-ruby that referenced this pull request Oct 11, 2024
Updated mmtk-core to fix a race that caused GC workers to sometimes
observe copied objects not having VO bits.  See:
mmtk/mmtk-core#1214

The ruby repo is merged with the official master branch.

Fixes: mmtk#106
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.

4 participants