Closed
Description
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:
- 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. - Initialize circular references.
I suggest we do these:
- As we are removing global states, we should remove the extra
init()
so that all the fields are initialized properly innew()
. We should do this wherever possible. - If we cannot remove
init()
, we should use a wrapper to properly indicate that this field might be uninitialized such asMaybeUninit<T>
. - 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.