Skip to content

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

Open

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)

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

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-sanitizersArea: Sanitizers for correctness and code qualityArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.Category: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.PG-exploit-mitigationsProject group: Exploit mitigationsProject group: Exploit mitigationsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some wayThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions