From 67b2925afa630d9fc75c423421fde0078dba0cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20St=C3=BCcker?= Date: Mon, 11 Sep 2023 10:14:52 +0200 Subject: [PATCH] Fix incorrect memory layout on Rust >= 1.67.0 --- .gitignore | 2 +- native/chromium/build.rs | 1 + native/chromium_subp/src/app/mod.rs | 5 +++++ native/chromium_subp/src/socket.rs | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3db8dea..183bb20 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,5 @@ cef_cache/ hs_err_pid*.log # Do not commit CEF binaries -/java-cef/org.eclipse.set.browser.cef/cef +/java/org.eclipse.set.browser.cef.win32/cef /cef \ No newline at end of file diff --git a/native/chromium/build.rs b/native/chromium/build.rs index b008415..879acc0 100644 --- a/native/chromium/build.rs +++ b/native/chromium/build.rs @@ -110,6 +110,7 @@ fn gen_cef(cef_path: std::path::Display) { dst.write(new_data.as_bytes()).expect("Cannot write mod.rs"); } +#[repr(C)] #[derive(Debug)] struct ToJavaCallbacks(); diff --git a/native/chromium_subp/src/app/mod.rs b/native/chromium_subp/src/app/mod.rs index 0716027..008ac1e 100644 --- a/native/chromium_subp/src/app/mod.rs +++ b/native/chromium_subp/src/app/mod.rs @@ -17,6 +17,7 @@ use std::ffi::{CStr, CString}; use std::mem; use std::os::raw::c_int; +#[repr(C)] pub struct Base {} impl Base { @@ -31,6 +32,7 @@ impl Base { } } +#[repr(C)] pub struct App { cef: chromium::cef::_cef_app_t, render_process_handler: RenderProcessHandler, @@ -76,10 +78,12 @@ impl App { } } +#[repr(C)] #[derive(Clone, Copy)] struct Browser(*mut chromium::cef::_cef_browser_t); unsafe impl Send for Browser {} +#[repr(C)] struct RenderProcessHandler { cef: chromium::cef::_cef_render_process_handler_t, function_handler: Option, @@ -307,6 +311,7 @@ unsafe fn convert_type( } } +#[repr(C)] struct V8Handler { cef: chromium::cef::_cef_v8handler_t, browser: *mut chromium::cef::_cef_browser_t, diff --git a/native/chromium_subp/src/socket.rs b/native/chromium_subp/src/socket.rs index 522a768..d2483e1 100644 --- a/native/chromium_subp/src/socket.rs +++ b/native/chromium_subp/src/socket.rs @@ -40,12 +40,14 @@ impl ReturnType { } } +#[repr(C)] #[derive(Debug, PartialEq, Eq)] pub struct ReturnSt { pub kind: ReturnType, pub str_value: CString, } +#[repr(C)] #[derive(Debug, PartialEq, Eq)] struct ReturnMsg { kind: ReturnType,