mmtk-core icon indicating copy to clipboard operation
mmtk-core copied to clipboard

Uninitialized Fields

Open qinsoon opened this issue 5 years ago • 3 comments

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.

qinsoon avatar Mar 26 '20 03:03 qinsoon

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

mentioned in merge request !22

qinsoon avatar Mar 26 '20 03:03 qinsoon

In GitLab by @qinsoon on Jan 26, 2020, 19:10

mentioned in merge request !23

qinsoon avatar Mar 26 '20 03:03 qinsoon

We have gradually removed the pattern. I am not aware of any unnecessary two-step initialisation in our code base. I feel we can close this issue now. If you find anything that is related with this issue and hasn't been addressed, please reply to this issue. Otherwise, I will close this issue soon.

qinsoon avatar Aug 08 '22 01:08 qinsoon

Closed as above

k-sareen avatar Aug 14 '23 23:08 k-sareen