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

Fix segfault in 1.77.0+ #113

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
Expand Down
22 changes: 10 additions & 12 deletions src/linux/thread_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading