From 06020698cf57c2b5fdffc596beea51351dcb6539 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 1 Apr 2024 14:31:29 +0200 Subject: [PATCH 1/3] Fix segfault in 1.77.0+ --- src/linux/thread_info.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/linux/thread_info.rs b/src/linux/thread_info.rs index 5bb1f9e8..a3fbed95 100644 --- a/src/linux/thread_info.rs +++ b/src/linux/thread_info.rs @@ -37,20 +37,18 @@ enum NT_Elf { NT_ARM_VFP = 0x400, // ARM VFP/NEON registers } -#[inline] -pub fn to_u128(slice: &[u32]) -> &[u128] { - unsafe { std::slice::from_raw_parts(slice.as_ptr().cast(), slice.len().saturating_div(4)) } -} - -#[inline] -pub fn copy_registers(dst: &mut [u128], src: &[u128]) { - let to_copy = std::cmp::min(dst.len(), src.len()); - dst[..to_copy].copy_from_slice(&src[..to_copy]); -} - #[inline] pub fn copy_u32_registers(dst: &mut [u128], src: &[u32]) { - copy_registers(dst, to_u128(src)); + // SAFETY: We are copying a block of memory from ptrace as u32s to the u128 + // format of minidump-common + unsafe { + let dst: &mut [u8] = + std::slice::from_raw_parts_mut(dst.as_mut_ptr().cast(), dst.len() * 16); + let src: &[u8] = std::slice::from_raw_parts(src.as_ptr().cast(), src.len() * 4); + + let to_copy = std::cmp::min(dst.len(), src.len()); + dst[..to_copy].copy_from_slice(&src[..to_copy]); + } } trait CommonThreadInfo { From 6d83c830ba8925bb5dc557858759eb7012bd0c37 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 1 Apr 2024 15:06:16 +0200 Subject: [PATCH 2/3] Add release testing for x86_64-unknown-linux-gnu --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 160af86b..5e1828da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: strategy: matrix: job: - - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu } + - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, release: true } - { os: ubuntu-22.04, target: x86_64-unknown-linux-musl } - { os: windows-2022, target: x86_64-pc-windows-msvc } - { os: macos-13, target: x86_64-apple-darwin } @@ -49,6 +49,11 @@ jobs: run: cargo test --target ${{ matrix.job.target }} --no-run - name: Test run: cargo test --target ${{ matrix.job.target }} + - name: Release test + if: ${{ matrix.job.release }} + run: + cargo test --target ${{ matrix.job.target }} --release --no-run + cargo test --target ${{ matrix.job.target }} --release install-cross: runs-on: ubuntu-latest From 1f4a2f0c6d77d9e4e8c8a2d11a54250279cc692d Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 1 Apr 2024 15:08:23 +0200 Subject: [PATCH 3/3] Sigh yaml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e1828da..c9a3e652 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: run: cargo test --target ${{ matrix.job.target }} - name: Release test if: ${{ matrix.job.release }} - run: + run: | cargo test --target ${{ matrix.job.target }} --release --no-run cargo test --target ${{ matrix.job.target }} --release