Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UB in LLVM FFI when passing zero or >1 bundle #123941

Merged
merged 1 commit into from Apr 15, 2024

Commits on Apr 15, 2024

  1. Fix UB in LLVM FFI when passing zero or >1 bundle

    Rust passes a *const &OperandBundleDef to these APIs, usually from a
    Vec<&OperandBundleDef> or so. Previously we were dereferencing that
    pointer and passing it to the ArrayRef constructor with some length (N).
    
    This meant that if the length was 0, we were dereferencing a pointer to
    nowhere, and if the length was >1 then loading the *second* element
    somewhere in LLVM would've been reading past the end.
    
    Since Rust can't hold OperandBundleDef by-value we're forced to indirect
    through a vector that copies out the OperandBundleDefs from the
    by-reference list on the Rust side in order to match the LLVM expected
    API.
    Mark-Simulacrum committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    bf3decc View commit details
    Browse the repository at this point in the history