rust icon indicating copy to clipboard operation
rust copied to clipboard

SIGSEGV during compilation when taking address of extern x86-interrupt fn

Open iximeow opened this issue 5 years ago • 2 comments

#![feature(abi_x86_interrupt)]

#[repr(C)]
pub struct Context<'a> {
    inner: &'a mut u8,
}

extern "x86-interrupt" fn isr(_: Context) { }

pub fn main() {
    println!("oops: {:x}", isr as usize);
}

yields

> rustc crash.rs 
Segmentation fault (core dumped)

Interestingly, it seems like #[repr(C)] is load-bearing? No crash without a repr on the argument type. Also no crash if the argument is zero-sized (even with #[repr(C)]).

iximeow avatar Dec 28 '19 08:12 iximeow

It seems like this might be related to https://github.com/rust-lang/rust/issues/63018, where this is also resulting in nonsense IR to LLVM?

iximeow avatar Dec 28 '19 08:12 iximeow

This no longer appears to crash?

workingjubilee avatar Aug 06 '22 08:08 workingjubilee

yup, looks like this was fixed in the last few years:

[17:53:33] # iximeow:~> ./crash
oops: 55fa21ef0ad0

neat!

iximeow avatar Oct 22 '22 00:10 iximeow