rust-lang / rust-lang/rust

LLVM ERROR: `Cannot lower invokes with arbitrary operand bundles yet!`

Open
#124,407 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM A-sanitizers C-bug I-crash PG-exploit-mitigations requires-debug-assertions T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code:

// Tests that C++ exceptions can unwind through Rust code run destructors and
// are caught by catch_unwind. Also tests that Rust panics can unwind through
// C++ code.

use std::panic::{catch_unwind, AssertUnwindSafe};

struct DropCheck<'a>(&'a mut bool);
impl<'a> Drop for DropCheck<'a> {
    fn drop(&mut self) {
        println!("DropCheck::drop");
        *self.0 = true;
    }
}

extern "C" {
    fn test_cxx_exception();
}

extern "C-unwind" {
    fn cxx_catch_callback(cb: extern "C-unwind" fn(), ok: *mut bool);
}

#[no_mangle]
extern "C-unwind" fn rust_catch_callback(cb: extern "C-unwind" fn(), rust_ok: &mut bool) {
    let _drop = DropCheck(rust_ok);
    cb();
    unreachable!("should have unwound instead of returned");
}

fn test_rust_panic() {
    extern "C-unwind" fn callback() {
        println!("throwing rust panic");
        panic!(1234i32);
    }

    let mut dropped = false;
    let mut cxx_ok = false;
    let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
        let _drop = DropCheck(&mut dropped);
        unsafe {
            cxx_catch_callback(callback, &mut cxx_ok);
        }
        unreachable!("should have unwound instead of returned");
    }));
    println!("caught rust panic");
    assert!(dropped);
    assert!(caught_unwind.is_err());
    let panic_obj = caught_unwind.unwrap_err();
    let panic_int = *panic_obj.downcast_ref::<i32>().unwrap();
    assert_eq!(panic_int, 1234);
    assert!(cxx_ok);
}

fn main() {
    unsafe { test_cxx_exception() };
    test_rust_panic();
}

Version information

rustc 1.79.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.79.0-dev
LLVM version: 18.1.4

Command:
/home/gh-matthiaskrgr/.rustup/toolchains/local-debug-assertions/bin/rustc -Zsanitizer=kcfi -Cpanic=abort

Program output

warning: panic message is not a string literal
  --> foo.rs:33:16
   |
33 |         panic!(1234i32);
   |                ^^^^^^^
   |
   = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
   = note: `#[warn(non_fmt_panics)]` on by default
help: add a "{}" format string to `Display` the message
   |
33 |         panic!("{}", 1234i32);
   |                +++++
help: or use std::panic::panic_any instead
   |
33 |         std::panic::panic_any(1234i32);
   |         ~~~~~~~~~~~~~~~~~~~~~

rustc: /home/gh-matthiaskrgr/vcs/github/rust_debug_assertions/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:3137: void llvm::SelectionDAGBuilder::visitInvoke(const llvm::InvokeInst&): Assertion `!I.hasOperandBundlesOtherThan( {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition, LLVMContext::OB_gc_live, LLVMContext::OB_funclet, LLVMContext::OB_cfguardtarget, LLVMContext::OB_clang_arc_attachedcall}) && "Cannot lower invokes with arbitrary operand bundles yet!"' failed.
Aborted (core dumped)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with foo.rs and the provided rustc command, then inspect llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp around visitInvoke and its operand-bundle assertion. Done means the reproducer no longer aborts with the reported LLVM error while preserving the unwind behavior shown in the program.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.