servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 117 forks source link

Custom auto rooter test crashes on windows 86 #462

Open jdm opened 5 years ago

jdm commented 5 years ago

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 5 years ago

It does not crash on macOS x86.

karlhelgason commented 5 years ago

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 https://github.com/rust-lang/rust/issues/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),
}