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

Unsafe Code Cleanup #97

Open
qinsoon opened this issue Jun 4, 2020 · 3 comments
Open

Unsafe Code Cleanup #97

qinsoon opened this issue Jun 4, 2020 · 3 comments
Labels
A-general Area: all code base (issues with this label may be divided into more concrete issues) C-refactoring Category: Refactoring G-safety Goal: Safety P-high Priority: High. A high-priority issue should be fixed as soon as possible.

Comments

@qinsoon
Copy link
Member

qinsoon commented Jun 4, 2020

The current code base pervasively uses unsafe code, especially to get mutable references from immutable reference/objects. This could include potential race condition and bugs. We should clean up the unsafe code to maximize the benefits of thread safety we can get from Rust's checks.

We should diagnose each of the unsafe cases, and categorize them: either 1) we need to use unsafe (mostly for performance reasons), or 2) we can refactor them into safe code. For 1), we should always encapsulate the unsafe code and make sure that they are correct.

@qinsoon qinsoon added this to the v0.1 milestone Jun 4, 2020
@qinsoon qinsoon added A-general Area: all code base (issues with this label may be divided into more concrete issues) C-refactoring Category: Refactoring G-safety Goal: Safety labels Jun 5, 2020
@qinsoon qinsoon modified the milestones: v0.1, v0.2 Nov 3, 2020
@qinsoon qinsoon removed this from the v0.2 milestone Dec 18, 2020
@qinsoon
Copy link
Member Author

qinsoon commented May 17, 2021

A quick summary of unsafe code in the current MMTk: https://docs.google.com/presentation/d/1X4unAoPeEPbnYoK95H2Fw54d0L139f8aYviDcoFFdqg/edit?usp=sharing

@qinsoon
Copy link
Member Author

qinsoon commented May 17, 2021

From our discussion, there are a few notes about unsafe code:

  • report some unsafe statistics from our CI for each PR.
  • properly document unsafe functions (# Safety in rustdoc) and document for the uses of those unsafe functions.
  • document our design around unsafe code in a separate markdown file in docs.
  • for intrinsic unsafety (e.g. accessing memory), we should think about how we can defend our code. They are unsafe, but we may provide some help for debugging if we can (e.g. in debug build, assert if an address is sane before accessing it?)

@qinsoon qinsoon added the P-high Priority: High. A high-priority issue should be fixed as soon as possible. label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-general Area: all code base (issues with this label may be divided into more concrete issues) C-refactoring Category: Refactoring G-safety Goal: Safety P-high Priority: High. A high-priority issue should be fixed as soon as possible.
Projects
None yet
Development

No branches or pull requests

1 participant