Skip to content

Tracking Issue for core::arch::return_address #154966

@chorman0773

Description

@chorman0773

Feature gate: #![feature(return_address)]

This is a tracking issue for core::arch::return_address

The core::arch::return_address!() macro returns a pointer with an address that corresponds to the caller of the function that invoked the return_address!() macro, or a null pointer if it cannot be determined, for debugging purposes

Public API

// core::arch

// Conceptual Signature: fn return_address() -> *const ();
pub macro return_address();

The core::arch::return_address!() macro returns a pointer with an address that corresponds to the caller of the function that invoked the return_address!() macro, or a null pointer if it cannot be determined. The pointer has no provenance, as if created by core::ptr::without_provenance. It cannot be used to read memory (other than ZSTs)

The value returned by the macro depends highly on the architecture and compiler (including any options set). In particular, it is allowed to be wrong (particularily if inlining is involved), or even contain a nonsense value. The result of this macro must not be relied upon for soundness or correctness, only for debugging purposes.
Formally, this function returns a pointer with a non-deterministic address and no provenance.

This is equivalent to the gcc __builtin_return_address(0) intrinsic (other forms of the intrinsic are not supported). Because the operation can be always performed by the compiler without crashing or causing undefined behaviour, invoking the macro is a safe operation.

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • Should this take the form of a macro or an #[inline(always)] function?
  • How should we handle "weird" architectures where pointers to code aren't the same size as pointers to data.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions