servo/rust-mozjs

Custom auto rooter test crashes on windows 86

jdm opened this issue · 2 comments

jdm commented

The crash occurs during the call to JS_GC, which suggests that the AutoGCRooter structure or CustomAutoRooter vtable is not correct for that arch.

jdm commented

It does not crash on macOS x86.

Visual C++ on x86 arch uses "thiscall" call convention for member functions.

The struct CustomAutoRooterVFTable as defined in
https://github.com/servo/mozjs/blob/master/src/jsgc.rs
is missing "thiscall" for x86 windows.

Unfortunately thiscall is only available in unstable rust
rust-lang/rust#42202

#[repr(C)]
pub struct CustomAutoRooterVFTable {
    #[cfg(windows)]
    pub padding: [usize; 1],
    #[cfg(not(windows))]
    pub padding: [usize; 2],
    #[cfg(all(windows, target_pointer_width = "32"))]
    pub trace: unsafe extern "thiscall" fn (this: *mut c_void, trc: *mut JSTracer),
    #[cfg(not(all(windows, target_pointer_width = "32")))]
    pub trace: unsafe extern "C" fn (this: *mut c_void, trc: *mut JSTracer),
}