Skip to content

Non-ZST stop static is probably unsound #98

@GoldsteinE

Description

@GoldsteinE

Currently linkme generates an extern static of Element type for the “stop section” symbol:

#[cfg_attr(any(target_os = "none", target_os = "linux", target_os = "android", target_os = "fuchsia", target_os = "psp"), link_name = #linux_section_stop)]
#[cfg_attr(any(target_os = "macos", target_os = "ios", target_os = "tvos"), link_name = #macho_section_stop)]
#[cfg_attr(target_os = "illumos", link_name = #illumos_section_stop)]
#[cfg_attr(any(target_os = "freebsd", target_os = "openbsd"), link_name = #bsd_section_stop)]
static LINKME_STOP: <#ty as #linkme_path::__private::Slice>::Element;

As pointed out in rust-lang/rust#46188 (comment), statics are considered always-dereferenceable, so it’s probably unsound. As the stop static is never actually read from, I think it could be made zero-sized to remove the unsoundness?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions