Skip to content

Commit 84733c5

Browse files
authored
Add testing of aarch64 linux (#96)
* Add testing of aarch64 linux * Ignore float state for now * Fix unneccessary stack copy * Adjust aarch64 error * Reenable CI
1 parent 6e61b46 commit 84733c5

File tree

5 files changed

+68
-32
lines changed

5 files changed

+68
-32
lines changed

.github/workflows/rust-ci.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
name: Lint
1717
strategy:
1818
matrix:
19-
os: [ubuntu-22.04, windows-2022, macos-14]
19+
os:
20+
- ubuntu-24.04
21+
- windows-2022
22+
- macos-14
23+
- ubuntu-24.04-arm
2024
runs-on: ${{ matrix.os }}
2125
steps:
2226
- uses: actions/checkout@v4
@@ -39,26 +43,28 @@ jobs:
3943
name: Test
4044
strategy:
4145
matrix:
42-
os: [ubuntu-22.04, windows-2022, macos-14]
46+
os:
47+
- ubuntu-24.04
48+
- windows-2022
49+
- macos-14
50+
- ubuntu-24.04-arm
4351
runs-on: ${{ matrix.os }}
4452
steps:
4553
- uses: actions/checkout@v4
4654
- uses: dtolnay/rust-toolchain@stable
4755
- uses: Swatinem/rust-cache@v2
4856
- run: cargo fetch
4957
- name: cargo test build
50-
run: cargo build --tests
58+
run: cargo build --tests --all-features
5159
- name: cargo test
52-
run: cargo test
60+
run: cargo test --all-features
5361

5462
build-android:
5563
name: Build sources
56-
runs-on: ubuntu-22.04
64+
runs-on: ubuntu-24.04
5765
strategy:
5866
matrix:
5967
job:
60-
#- { target: aarch64-unknown-linux-gnu, toolchain: stable }
61-
- { target: aarch64-unknown-linux-musl, toolchain: stable }
6268
- { target: aarch64-linux-android, toolchain: stable }
6369
- { target: arm-unknown-linux-gnueabihf, toolchain: stable }
6470
steps:
@@ -82,14 +88,14 @@ jobs:
8288
8389
deny-check:
8490
name: cargo-deny
85-
runs-on: ubuntu-22.04
91+
runs-on: ubuntu-24.04
8692
steps:
8793
- uses: actions/checkout@v4
8894
- uses: EmbarkStudios/cargo-deny-action@v2
8995

9096
publish-check:
9197
name: Publish Check
92-
runs-on: ubuntu-22.04
98+
runs-on: ubuntu-24.04
9399
steps:
94100
- uses: actions/checkout@v4
95101
- uses: dtolnay/rust-toolchain@stable
@@ -103,7 +109,7 @@ jobs:
103109
cargo publish --dry-run --manifest-path sadness-generator/Cargo.toml
104110
105111
all:
106-
runs-on: ubuntu-22.04
112+
runs-on: ubuntu-24.04
107113
needs: [lint, test, build-android, deny-check, publish-check]
108114
steps:
109115
- run: echo "All test jobs passed"

crash-handler/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use error::Error;
99
#[macro_export]
1010
macro_rules! debug_print {
1111
($s:literal) => {
12-
let cstr = concat!($s, "\n");
12+
let cstr = concat!(file!(), ":", line!(), " ", $s, "\n");
1313
$crate::write_stderr(cstr);
1414
};
1515
}

crash-handler/src/linux/state.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ unsafe extern "C" fn signal_handler(
402402

403403
/// The size of `CrashContext` can be too big w.r.t the size of alternatate stack
404404
/// for `signal_handler`. Keep the crash context as a .bss field.
405-
static CRASH_CONTEXT: parking_lot::Mutex<mem::MaybeUninit<crash_context::CrashContext>> =
406-
parking_lot::const_mutex(mem::MaybeUninit::uninit());
405+
static CRASH_CONTEXT: parking_lot::Mutex<crash_context::CrashContext> =
406+
parking_lot::const_mutex(unsafe { mem::zeroed() });
407407

408408
pub(super) struct HandlerInner {
409409
handler: Box<dyn crate::CrashEvent>,
@@ -430,18 +430,25 @@ impl HandlerInner {
430430
// that we require
431431
let nix_info = &*((info as *const libc::siginfo_t).cast::<libc::signalfd_siginfo>());
432432

433+
debug_print!("acquired siginfo");
434+
433435
// Allow ourselves to be dumped, if that is what the user handler wishes to do
434436
let _set_dumpable = SetDumpable::new(self.dump_process);
435-
let mut crash_ctx = CRASH_CONTEXT.lock();
437+
debug_print!("set dumpable");
438+
let mut cc = CRASH_CONTEXT.lock();
436439

437440
{
438-
*crash_ctx = mem::MaybeUninit::zeroed();
439-
let cc = &mut *crash_ctx.as_mut_ptr();
441+
use std::ops::DerefMut;
442+
#[allow(clippy::explicit_deref_methods)]
443+
ptr::write_bytes(cc.deref_mut(), 0, 1);
444+
debug_print!("zeroed crashctx");
440445

441446
ptr::copy_nonoverlapping(nix_info, &mut cc.siginfo, 1);
447+
debug_print!("copied siginfo");
442448

443449
let uc_ptr = &*(uc as *const libc::c_void).cast::<crash_context::ucontext_t>();
444450
ptr::copy_nonoverlapping(uc_ptr, &mut cc.context, 1);
451+
debug_print!("copied context");
445452

446453
cfg_if::cfg_if! {
447454
if #[cfg(target_arch = "aarch64")] {
@@ -453,7 +460,6 @@ impl HandlerInner {
453460
} else if #[cfg(not(target_arch = "arm"))] {
454461
if !uc_ptr.uc_mcontext.fpregs.is_null() {
455462
ptr::copy_nonoverlapping(uc_ptr.uc_mcontext.fpregs, ((&mut cc.float_state) as *mut crash_context::fpregset_t).cast(), 1);
456-
457463
}
458464
}
459465
}
@@ -462,7 +468,7 @@ impl HandlerInner {
462468
cc.tid = libc::syscall(libc::SYS_gettid) as i32;
463469
}
464470

465-
self.handler.on_crash(&*crash_ctx.as_ptr())
471+
self.handler.on_crash(&cc)
466472
}
467473
}
468474
}

minidumper-test/src/lib.rs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ pub fn assert_minidump(md_buf: &[u8], signal: Signal) {
315315
($expected:pat) => {
316316
assert!(
317317
matches!(crash_reason, $expected),
318-
"crash reason: {:?}",
319-
crash_reason
318+
"crash reason: {crash_reason:?}",
320319
);
321320
};
322321
}
@@ -336,14 +335,27 @@ pub fn assert_minidump(md_buf: &[u8], signal: Signal) {
336335
));
337336
}
338337
Signal::Fpe => {
339-
verify!(CrashReason::LinuxSigfpe(
340-
errors::ExceptionCodeLinuxSigfpeKind::FPE_INTDIV
341-
));
338+
if cfg!(not(any(target_arch = "aarch64", target_arch = "arm"))) {
339+
verify!(CrashReason::LinuxSigfpe(
340+
errors::ExceptionCodeLinuxSigfpeKind::FPE_INTDIV
341+
));
342+
} else {
343+
verify!(CrashReason::LinuxGeneral(
344+
errors::ExceptionCodeLinux::SIGFPE,
345+
4294967290
346+
));
347+
}
342348
}
343349
Signal::Illegal => {
344-
verify!(CrashReason::LinuxSigill(
345-
errors::ExceptionCodeLinuxSigillKind::ILL_ILLOPN
346-
));
350+
if cfg!(not(any(target_arch = "aarch64", target_arch = "arm"))) {
351+
verify!(CrashReason::LinuxSigill(
352+
errors::ExceptionCodeLinuxSigillKind::ILL_ILLOPN
353+
));
354+
} else {
355+
verify!(CrashReason::LinuxSigill(
356+
errors::ExceptionCodeLinuxSigillKind::ILL_ILLOPC
357+
));
358+
}
347359
}
348360
Signal::Segv => {
349361
verify!(CrashReason::LinuxSigsegv(
@@ -362,10 +374,16 @@ pub fn assert_minidump(md_buf: &[u8], signal: Signal) {
362374
));
363375
}
364376
Signal::Trap => {
365-
verify!(CrashReason::LinuxGeneral(
366-
errors::ExceptionCodeLinux::SIGTRAP,
367-
_
368-
));
377+
if cfg!(not(any(target_arch = "aarch64", target_arch = "arm"))) {
378+
verify!(CrashReason::LinuxGeneral(
379+
errors::ExceptionCodeLinux::SIGTRAP,
380+
_
381+
));
382+
} else {
383+
verify!(CrashReason::LinuxSigtrap(
384+
errors::ExceptionCodeLinuxSigtrapKind::TRAP_BRKPT
385+
));
386+
}
369387
}
370388
#[cfg(windows)]
371389
Signal::Purecall | Signal::InvalidParameter | Signal::HeapCorruption => {

minidumper/src/ipc/server.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,15 @@ impl Server {
455455

456456
cfg_if::cfg_if! {
457457
if #[cfg(any(target_os = "linux", target_os = "android"))] {
458+
#[allow(unsafe_code)]
459+
let crash_context = minidump_writer::crash_context::CrashContext {
460+
inner: unsafe { std::mem::transmute_copy(&crash_context) },
461+
};
462+
458463
let mut writer =
459-
minidump_writer::minidump_writer::MinidumpWriter::new(crash_context.pid, crash_context.tid);
460-
writer.set_crash_context(minidump_writer::crash_context::CrashContext { inner: crash_context });
464+
minidump_writer::minidump_writer::MinidumpWriter::new(crash_context.inner.pid, crash_context.inner.tid);
465+
466+
writer.set_crash_context(crash_context);
461467
} else if #[cfg(target_os = "windows")] {
462468
// SAFETY: Unfortunately this is a bit dangerous since we are relying on the crashing process
463469
// to still be alive and still have the interior pointers in the crash context still at the

0 commit comments

Comments
 (0)