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

macOS builds are broken with recent rustc #312

Closed
jdm opened this issue Jun 4, 2023 · 2 comments
Closed

macOS builds are broken with recent rustc #312

jdm opened this issue Jun 4, 2023 · 2 comments

Comments

@jdm
Copy link
Member

jdm commented Jun 4, 2023

rust-lang/rust#98112 identifies an unaligned write that occurs:

thread '<unnamed>' panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x7fa07c701059', src/platform/macos/mod.rs:539:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'panic in a function that cannot unwind', library/core/src/panicking.rs:126:5
stack backtrace:
   0:        0x104632e43 - std::backtrace_rs::backtrace::libunwind::trace::h8c19cce8ed8ccf51
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x104632e43 - std::backtrace_rs::backtrace::trace_unsynchronized::h991e04b43bc79443
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x104632e43 - std::sys_common::backtrace::_print_fmt::h8987ba788c846a85
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys_common/backtrace.rs:65:5
   3:        0x104632e43 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0a694d0e7599586c
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x10464f49b - core::fmt::rt::Argument::fmt::h0a8aa1334c46e31c
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/fmt/rt.rs:138:9
   5:        0x10464f49b - core::fmt::write::h3efe3f464ccee79e
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/fmt/mod.rs:1094:21
   6:        0x104630148 - std::io::Write::write_fmt::h0e2bb4c22bdace59
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/io/mod.rs:1713:15
   7:        0x104632c3a - std::sys_common::backtrace::_print::h718192d6d9e6c0a5
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x104632c3a - std::sys_common::backtrace::print::hbdaa3eeb7c563975
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x1046346f5 - std::panicking::default_hook::{{closure}}::hed147903f5cf7c57
  10:        0x1046344ff - std::panicking::default_hook::hfcf98064a6736dfc
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panicking.rs:288:9
  11:        0x1045b5946 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9bbb1f1d9a50e95e
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/alloc/src/boxed.rs:1999:9
  12:        0x1045b5946 - test::test_main::{{closure}}::h253e00dda88e7637
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/test/src/lib.rs:134:21
  13:        0x104634d0a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h02bfaba73002fb16
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/alloc/src/boxed.rs:1999:9
  14:        0x104634d0a - std::panicking::rust_panic_with_hook::h07218173ef7e2e36
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panicking.rs:709:13
  15:        0x104634a72 - std::panicking::begin_panic_handler::{{closure}}::h8f1360464839a927
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panicking.rs:595:13
  16:        0x104633249 - std::sys_common::backtrace::__rust_end_short_backtrace::hb22d1d0c8f75c030
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys_common/backtrace.rs:151:18
  17:        0x1046347ed - rust_begin_unwind
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panicking.rs:593:5
  18:        0x10465be63 - core::panicking::panic_nounwind_fmt::h3d8629ceefa59b23
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/panicking.rs:96:14
  19:        0x10465bf0b - core::panicking::panic_nounwind::hd768f4ccdfcb86a4
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/panicking.rs:126:5
  20:        0x10465c075 - core::panicking::panic_cannot_unwind::h4f579b1494f7e1d8
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/panicking.rs:188:5
  21:        0x1044b8856 - ipc_channel::platform::macos::OsIpcSender::send::hf10dfb749918bc7a
                               at /Users/jdm/src/ipc-channel/src/platform/macos/mod.rs:480:5
  22:        0x10457c170 - ipc_channel::platform::test::big_data_with_5_fds::{{closure}}::ha84e55d4172d7df0
                               at /Users/jdm/src/ipc-channel/src/platform/test.rs:310:17
  23:        0x10455428d - std::sys_common::backtrace::__rust_begin_short_backtrace::h3841e5dc8595b5b9
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys_common/backtrace.rs:135:18
  24:        0x10446e830 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h728edd4a235b5cd5
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/thread/mod.rs:529:17
  25:        0x10456d460 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h1c6f72c1057fbc08
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/panic/unwind_safe.rs:271:9
  26:        0x104555db4 - std::panicking::try::do_call::h6c132ae3ed4c8cbb
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panicking.rs:500:40
  27:        0x104556f9d - ___rust_try
  28:        0x104555159 - std::panicking::try::h7fd1d38e673dd57f
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panicking.rs:464:19
  29:        0x10446b91e - std::panic::catch_unwind::h4e227a1b4a215733
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/panic.rs:142:14
  30:        0x10446b91e - std::thread::Builder::spawn_unchecked_::{{closure}}::h606ea262f5ae4d61
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/thread/mod.rs:528:30
  31:        0x1044d9841 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0152d430eb975234
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/core/src/ops/function.rs:250:5
  32:        0x1046390b9 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h860f224c375c943e
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/alloc/src/boxed.rs:1985:9
  33:        0x1046390b9 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h746ad73385688dbd
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/alloc/src/boxed.rs:1985:9
  34:        0x1046390b9 - std::sys::unix::thread::Thread::new::thread_start::hed672fe9ad457508
                               at /rustc/398fa2187c88de46c13c142f600064483a563c86/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7ff802b4b4e1 - __pthread_start
@jdm
Copy link
Member Author

jdm commented Jun 5, 2023

I've created a branch that I thought would address this problem. The assertion has disappeared, but various tests are failing for reasons that I do not yet understand. Eg. platform::test::huge_data correctly sends a large buffer as an OOL shared memory region, but when the receive call happens the address of the shared memory region is null (even though all of the other data members are sent correctly).

mukilan added a commit to mukilan/ipc-channel that referenced this issue Jun 22, 2023
The current 'mach_sys.rs' was generated before rust-bindgen
started translating '#pragma pack(n)' directives into
'#[repr(C, packed(n)]' attributes on the rust struct defintions.
These missing attributes cause debug assertions to fail
because of misaligned access to the fields when serializing
and deserializing the structs for mach_msg calls (see servo#312).

This PR regenerates the 'mach_sys.rs' file using the
latest bindgen and mach headers from XCode MacOS SDK.
It also introduces padding *before* the 'data size' field
for messages with inline data so that they begin at
8-byte aligned addresses as required by rustc.

Signed-off-by: Mukilan Thiyagarajan <me@mukilan.in>
mukilan added a commit that referenced this issue Jun 23, 2023
The current 'mach_sys.rs' was generated before rust-bindgen
started translating '#pragma pack(n)' directives into
'#[repr(C, packed(n)]' attributes on the rust struct defintions.
These missing attributes cause debug assertions to fail
because of misaligned access to the fields when serializing
and deserializing the structs for mach_msg calls (see #312).

This PR regenerates the 'mach_sys.rs' file using the
latest bindgen and mach headers from XCode MacOS SDK.
It also introduces padding *before* the 'data size' field
for messages with inline data so that they begin at
8-byte aligned addresses as required by rustc.

Signed-off-by: Mukilan Thiyagarajan <me@mukilan.in>
@mukilan
Copy link
Member

mukilan commented Aug 8, 2023

Closed via #314

@mukilan mukilan closed this as completed Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants