Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cppgc: object alignment is not guaranteed for alignment > 8 #1676

Closed
lucacasonato opened this issue Jan 3, 2025 · 0 comments · Fixed by #1677
Closed

cppgc: object alignment is not guaranteed for alignment > 8 #1676

lucacasonato opened this issue Jan 3, 2025 · 0 comments · Fixed by #1677
Labels
bug Something isn't working

Comments

@lucacasonato
Copy link
Member

lucacasonato commented Jan 3, 2025

Right now our cppgc bindings indisciminantly align all objects to 8 bytes. This is problematic if the actual alignment required by T in cppgc::make_garbage_collected<T> is larger than 8, such as when T contains a u128 (where alignment needs to be 16).

You can experience a related SIGSEGV by changing the tests as follows, and running in release (at least on Linux amd64):

--- a/tests/test_cppgc.rs
+++ b/tests/test_cppgc.rs
@@ -36,6 +36,7 @@ fn cppgc_object_wrap() {
   static DROP_COUNT: AtomicUsize = AtomicUsize::new(0);
 
   struct Wrap {
+    force_align: u128,
     value: v8::TracedReference<v8::Value>,
   }
 
@@ -73,6 +74,7 @@ fn cppgc_object_wrap() {
     assert!(obj.is_api_wrapper());
 
     let wrap = Wrap {
+      force_align: 0,
       value: v8::TracedReference::new(scope, args.get(0)),
     };
     let member = unsafe {
@lucacasonato lucacasonato added the bug Something isn't working label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant