-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Add -Zrandomize-layout flag to better detect code that rely on unspecified behavior related to memory layout #77316
Copy link
Copy link
Closed
Labels
-Zrandomize-layoutUnstable option: Randomize the layout of types.Unstable option: Randomize the layout of types.A-layoutArea: Memory layout of typesArea: Memory layout of typesC-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
-Zrandomize-layoutUnstable option: Randomize the layout of types.Unstable option: Randomize the layout of types.A-layoutArea: Memory layout of typesArea: Memory layout of typesC-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In order to better detect code that rely on unspecified behavior related to memory layout, it could be useful to have a
-Zrandomize-layoutflag that add some padding bytes at the start of all#[repr(rust)]structs and unions. It should also add different amounts of padding to different fields.This should help detecting invalid transmutes, or invalid unions.
Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Transmute.20safety.20question