Starlight-JS / starlight

JS engine in Rust
https://teletype.in/@starlight-js
Mozilla Public License 2.0
511 stars 9 forks source link

Windows segfaults #78

Closed playXE closed 3 years ago

playXE commented 3 years ago

Since 6d4a40bae14bd18341063c927bc9aa0cd044a891 windows CI build segfaults when test262 is running. I do not have Windows machine and can't investigate in this issue

cc @jameslahm

playXE commented 3 years ago

Maybe the problem is there?

 #[inline]
    pub fn copy<T: GcCell>(&mut self, value: GcPointer<T>) -> GcPointer<T> {
        let obj = value.deref();
        let size = value.compute_size();
        let memory = self.allocate_raw(vtable_of(obj) as _, size, TypeId::of::<T>());
        unsafe {
            let base = &*(value.base.as_ptr());
            for index in 0..size {
                let pos = (base.data::<u8>() as usize + index) as *mut u8;
                (*memory).data::<u8>().write(*pos);
            }
            GcPointer {
                base: NonNull::new_unchecked(memory),
                marker: PhantomData,
            }
        }
    }

You do not have to copy entire GcPointerBase but just value part which is after GcPointerBase and I think problem is because copy happens to wrong place. I'll try to fix this function and see what happens.

EDIT: This code actually looks correct, I'll just try to replace it with copy_nonoverlapping

playXE commented 3 years ago

95e506e7036f42c5b39f3968f404c456d0b2a512 seems to solve it