immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.91k stars 229 forks source link

analyze: borrowck assertion failure on statics with hypothetical region params #943

Closed spernsteiner closed 1 year ago

spernsteiner commented 1 year ago

Test case:

// Regression test for an assertion failure in `borrowck::type_check` `do_assign` related to
// mismatched numbers of origin params when accessing statics.

static mut oneshot_fdn: fdnode = fdnode { ctx: 0 as *mut u8 };

pub struct fdnode {
    pub ctx: *mut u8,
}

unsafe extern "C" fn server_free() -> bool {
    oneshot_fdn.ctx.is_null()
}

Panics on this assertion:

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', c2rust-analyze/src/borrowck/type_check.rs:423:13

This error currently appears in 44 places in lighttpd