Skip to content

CFI typeid encode_ty todo! ICE on ty::UnsafeBinder #602

Description

@SebTardif

Summary

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs encode_ty has todo!() on ty::UnsafeBinder(_). If LLVM CFI / KCFI type metadata is requested for a function whose signature mentions an unstable unsafe-binder type, rustc ICEs instead of emitting a typeid.

Unsafe binders are transparent at the type level for most queries; encoding the region-erased inner type is consistent with symbol mangling (v0 / PR #581 pattern) and other UnsafeBinder arms.

Origin

Audit of incomplete TyKind / UnsafeBinder match arms in the compiler, SebTardif/rust fork of rust-lang/rust.

Affected code (upstream tip at audit time)

https://github.com/rust-lang/rust/blob/f28ac764c36/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs#L595-L598

// FIXME(unsafe_binders): Implement this.
ty::UnsafeBinder(_) => {
    todo!()
}

Suggested fix

ty::UnsafeBinder(bound_ty) => {
    let inner = tcx.instantiate_bound_regions_with_erased((*bound_ty).into());
    typeid.push_str(&encode_ty(tcx, inner, dict, options));
}

Impact

Low-to-medium, gated on unstable unsafe_binders plus CFI/KCFI sanitizer builds. Without the feature, this arm is unreachable in practice. With it, ICE is a hard failure for affected crates.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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