Skip to content

Uninitialized Fields #57

Closed
Closed
@qinsoon

Description

@qinsoon

In GitLab by @qinsoon on Jan 26, 2020, 11:44

A lot of structs in Rust MMTk are initialized with some uninitialized fields. We are using empty values (such as 0, OpaquePointer::EMPTY), mem::uninitialized(), or Option::None for the uninitialized fields.

The reasons why those uninitialized fields exist are:

  1. Rust MMTk used to create some structs as static variables, some fields are uninitialized. Rust MMTk relies on an extra init() step to properly set values for those fields.
  2. Initialize circular references.

I suggest we do these:

  1. As we are removing global states, we should remove the extra init() so that all the fields are initialized properly in new(). We should do this wherever possible.
  2. If we cannot remove init(), we should use a wrapper to properly indicate that this field might be uninitialized such as MaybeUninit<T>.
  3. Remove circular references if we can.

This issue is raised in code reviews for both https://gitlab.anu.edu.au/mmtk/mmtk/merge_requests/20 and https://gitlab.anu.edu.au/mmtk/mmtk/merge_requests/22.

Metadata

Metadata

Assignees

Labels

A-generalArea: all code base (issues with this label may be divided into more concrete issues)C-refactoringCategory: RefactoringS-stale:end:Status: Stale (will be closed soon)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions