Skip to content
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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
Expand All @@ -32,11 +32,11 @@ jobs:
strategy:
matrix:
job:
- { 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 }
- { os: macos-14, target: aarch64-apple-darwin }
- { os: ubuntu-24.04, target: x86_64-unknown-linux-gnu, release: true }
- { os: ubuntu-24.04, target: x86_64-unknown-linux-musl }
- { os: windows-2025, target: x86_64-pc-windows-msvc }
- { os: macos-15-intel, target: x86_64-apple-darwin }
- { os: macos-15, target: aarch64-apple-darwin }
steps:
- uses: actions/checkout@v4
- name: Install Rust
Expand All @@ -56,7 +56,7 @@ jobs:
cargo test --target ${{ matrix.job.target }} --release

install-cross:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: XAMPPRocky/get-github-release@v1
id: cross
Expand All @@ -73,7 +73,7 @@ jobs:
# This job builds and tests non-tier1 targets
build_lower_tier:
name: Build sources
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: install-cross
strategy:
matrix:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
# interacts with this job.
test-android:
name: Test android
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
ANDROID_HOME: /usr/local/lib/android/sdk
steps:
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
cargo test --target x86_64-linux-android

deny-check:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: deny check
Expand Down
3 changes: 1 addition & 2 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,13 @@ mod windows {
GetThreadContext(GetCurrentThread(), exception_context.as_mut_ptr());

let mut exception_context = exception_context.assume_init();
exception_record.ExceptionCode = exception_code as _;

let exception_ptrs = crash_context::EXCEPTION_POINTERS {
ExceptionRecord: &mut exception_record,
ContextRecord: &mut exception_context,
};

exception_record.ExceptionCode = exception_code as _;

let exc_ptr_addr = &exception_ptrs as *const _ as usize;

println!("{pid} {exc_ptr_addr} {tid} {exception_code:x}");
Expand Down
137 changes: 48 additions & 89 deletions src/linux/minidump_writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,91 +369,60 @@ impl MinidumpWriter {
let dirent = self.write_memory_info_list_stream(buffer)?;
dir_section.write_to_file(buffer, Some(dirent))?;

let dirent = match write_file(buffer, "/proc/cpuinfo") {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxCpuInfo as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteCpuInfoFailed(e));
Default::default()
}
let mut proc_root = {
let mut pr = String::with_capacity(24);
use std::fmt::Write;
write!(&mut pr, "/proc/{}/", self.blamed_thread).unwrap(); // infallbile barring OOM
pr
};
dir_section.write_to_file(buffer, Some(dirent))?;

let dirent = match write_file(buffer, &format!("/proc/{}/status", self.blamed_thread)) {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxProcStatus as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteThreadProcStatusFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
macro_rules! file_entry {
(res $write:expr, $kind:ident, $err:ident) => {
let dirent = match $write {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::$kind as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::$err(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
};
($fname:literal, $kind:ident, $err:ident) => {
let trunc = proc_root.len();
proc_root.push_str($fname);

let dirent = match write_file(buffer, "/etc/lsb-release")
.or_else(|_| write_file(buffer, "/etc/os-release"))
{
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxLsbRelease as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteOsReleaseInfoFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
file_entry!(res write_file(buffer, &proc_root), $kind, $err);

let dirent = match write_file(buffer, &format!("/proc/{}/cmdline", self.blamed_thread)) {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxCmdLine as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteCommandLineFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
proc_root.truncate(trunc);
};
}

let dirent = match write_file(buffer, &format!("/proc/{}/environ", self.blamed_thread)) {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxEnviron as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteEnvironmentFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
file_entry!(
res write_file(buffer, "/proc/cpuinfo"),
LinuxCpuInfo,
WriteCpuInfoFailed
);
file_entry!("status", LinuxProcStatus, WriteThreadProcStatusFailed);

let dirent = match write_file(buffer, &format!("/proc/{}/auxv", self.blamed_thread)) {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxAuxv as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteAuxvFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
// Unfortunately neither of these files exist on Android, and there doesn't seem
// to be a way to read equivalent information from elsewhere on the file system
#[cfg(not(target_os = "android"))]
{
file_entry!(
res write_file(buffer, "/etc/lsb-release")
.or_else(|_| write_file(buffer, "/etc/os-release")),
LinuxLsbRelease,
WriteOsReleaseInfoFailed
);
}

let dirent = match write_file(buffer, &format!("/proc/{}/maps", self.blamed_thread)) {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::LinuxMaps as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteMapsFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
file_entry!("cmdline", LinuxCmdLine, WriteCommandLineFailed);
file_entry!("environ", LinuxEnviron, WriteEnvironmentFailed);
file_entry!("auxv", LinuxAuxv, WriteEnvironmentFailed);
file_entry!("maps", LinuxMaps, WriteMapsFailed);

let dirent = match dso_debug::write_dso_debug_stream(buffer, self.process_id, &self.auxv) {
Ok(dirent) => dirent,
Expand All @@ -464,17 +433,7 @@ impl MinidumpWriter {
};
dir_section.write_to_file(buffer, Some(dirent))?;

let dirent = match write_file(buffer, &format!("/proc/{}/limits", self.blamed_thread)) {
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::MozLinuxLimits as u32,
location,
},
Err(e) => {
soft_errors.push(WriterError::WriteLimitsFailed(e));
Default::default()
}
};
dir_section.write_to_file(buffer, Some(dirent))?;
file_entry!("limits", MozLinuxLimits, WriteLimitsFailed);

let dirent = self.write_thread_names_stream(buffer)?;
dir_section.write_to_file(buffer, Some(dirent))?;
Expand Down
7 changes: 4 additions & 3 deletions src/windows/minidump_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ impl MinidumpWriter {
ec.assume_init()
};

let mut exception_record: EXCEPTION_RECORD = std::mem::zeroed();
let mut exception_record = EXCEPTION_RECORD {
ExceptionCode: exception_code,
..std::mem::zeroed()
};

let exception_ptrs = EXCEPTION_POINTERS {
ExceptionRecord: &mut exception_record,
ContextRecord: &mut exception_context,
};

exception_record.ExceptionCode = exception_code;

let cc = crash_context::CrashContext {
exception_pointers: (&exception_ptrs as *const EXCEPTION_POINTERS).cast(),
process_id: std::process::id(),
Expand Down
50 changes: 26 additions & 24 deletions tests/linux_minidump_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,32 @@ contextual_test! {
let _: MinidumpThreadList = dump.get_stream().expect("Couldn't find MinidumpThreadList");
let _: MinidumpMemoryList = dump.get_stream().expect("Couldn't find MinidumpMemoryList");
let _: MinidumpSystemInfo = dump.get_stream().expect("Couldn't find MinidumpSystemInfo");
let _ = dump
.get_raw_stream(LinuxCpuInfo as u32)
.expect("Couldn't find LinuxCpuInfo");
let _ = dump
.get_raw_stream(LinuxProcStatus as u32)
.expect("Couldn't find LinuxProcStatus");
let _ = dump
.get_raw_stream(LinuxCmdLine as u32)
.expect("Couldn't find LinuxCmdLine");
let _ = dump
.get_raw_stream(LinuxEnviron as u32)
.expect("Couldn't find LinuxEnviron");
let _ = dump
.get_raw_stream(LinuxAuxv as u32)
.expect("Couldn't find LinuxAuxv");
let _ = dump
.get_raw_stream(LinuxMaps as u32)
.expect("Couldn't find LinuxMaps");
let _ = dump
.get_raw_stream(LinuxDsoDebug as u32)
.expect("Couldn't find LinuxDsoDebug");
let _ = dump
.get_raw_stream(MozLinuxLimits as u32)
.expect("Couldn't find MozLinuxLimits");

macro_rules! raw {
(get $kind:ident) => {{
dump
.get_raw_stream($kind as u32)
.expect(concat!("Couldn't find ", stringify!($kind)))
}};
($kind:ident) => {
let _ = dump
.get_raw_stream($kind as u32)
.expect(concat!("Couldn't find ", stringify!($kind)));
};
}

raw!(LinuxCpuInfo);
raw!(LinuxProcStatus);
raw!(LinuxLsbRelease);

let cmd_line = raw!(get LinuxCmdLine);
assert!(std::str::from_utf8(cmd_line).expect("cmd line was not utf8").ends_with("\0spawn_mmap_wait\0"));

raw!(LinuxEnviron);
raw!(LinuxAuxv);
raw!(LinuxMaps);
raw!(LinuxDsoDebug);
raw!(MozLinuxLimits);
}
}

Expand Down
Loading
Loading