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

Check the note names when looking for the GNU build ID on Linux #74

Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mach2 = "0.4"
# due to massive version churn
[target.'cfg(target_os = "windows")'.dependencies.winapi]
version = "0.3"
features = ["minwindef", "processthreadsapi", "winnt"]
features = ["handleapi", "minwindef", "processthreadsapi", "winnt"]

[dev-dependencies]
# Minidump-processor is async so we need an executor
Expand Down
2 changes: 1 addition & 1 deletion src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod linux {
fn test_file_id() -> Result<()> {
let ppid = getppid().as_raw();
let exe_link = format!("/proc/{}/exe", ppid);
let exe_name = std::fs::read_link(&exe_link)?.into_os_string();
let exe_name = std::fs::read_link(exe_link)?.into_os_string();
let mut dumper = PtraceDumper::new(getppid().as_raw())?;
let mut found_exe = None;
for (idx, mapping) in dumper.mappings.iter().enumerate() {
Expand Down
6 changes: 3 additions & 3 deletions src/dir_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
mem_writer::{Buffer, MemoryArrayWriter, MemoryWriterError},
minidump_format::MDRawDirectory,
};
use std::io::{Error, Seek, SeekFrom, Write};
use std::io::{Error, Seek, Write};

pub type DumpBuf = Buffer;

Expand Down Expand Up @@ -44,7 +44,7 @@ where
Ok(Self {
curr_idx: 0,
section: dir_section,
destination_start_offset: destination.seek(SeekFrom::Current(0))?,
destination_start_offset: destination.stream_position()?,
destination,
last_position_written_to_file: 0,
})
Expand All @@ -65,7 +65,7 @@ where
// Now write it to file

// First get all the positions
let curr_file_pos = self.destination.seek(SeekFrom::Current(0))?;
let curr_file_pos = self.destination.stream_position()?;
let idx_pos = self.section.location_of_index(self.curr_idx);
self.curr_idx += 1;

Expand Down
4 changes: 2 additions & 2 deletions src/linux/minidump_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl MinidumpWriter {
return true;
}

let (stack_ptr, stack_len) = match dumper.get_stack_info(stack_pointer as usize) {
let (stack_ptr, stack_len) = match dumper.get_stack_info(stack_pointer) {
Ok(x) => x,
Err(_) => {
return false;
Expand All @@ -173,7 +173,7 @@ impl MinidumpWriter {
}
};

let sp_offset = stack_pointer as usize - stack_ptr;
let sp_offset = stack_pointer - stack_ptr;
self.principal_mapping
.as_ref()
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions src/linux/ptrace_dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@ impl PtraceDumper {
) -> Option<&'data [u8]> {
if let Some(mut notes) = elf_obj.iter_note_headers(mem_slice) {
while let Some(Ok(note)) = notes.next() {
if note.n_type == elf::note::NT_GNU_BUILD_ID {
if (note.name == "GNU") && (note.n_type == elf::note::NT_GNU_BUILD_ID) {
return Some(note.desc);
}
}
}
if let Some(mut notes) = elf_obj.iter_note_sections(mem_slice, Some(".note.gnu.build-id")) {
while let Some(Ok(note)) = notes.next() {
if note.n_type == elf::note::NT_GNU_BUILD_ID {
if (note.name == "GNU") && (note.n_type == elf::note::NT_GNU_BUILD_ID) {
return Some(note.desc);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/linux/sections/exception_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub fn write(
) -> Result<MDRawDirectory, errors::SectionExceptionStreamError> {
let exception = if let Some(context) = &config.crash_context {
MDException {
exception_code: context.inner.siginfo.ssi_signo as u32,
exception_code: context.inner.siginfo.ssi_signo,
exception_flags: context.inner.siginfo.ssi_code as u32,
exception_address: context.inner.siginfo.ssi_addr as u64,
exception_address: context.inner.siginfo.ssi_addr,
..Default::default()
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/linux/sections/thread_list_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ pub fn write(
// unhelpful.
if config.crash_context.is_some() && thread.thread_id == config.blamed_thread as u32 {
let crash_context = config.crash_context.as_ref().unwrap();
let instruction_ptr = crash_context.get_instruction_pointer() as usize;
let stack_pointer = crash_context.get_stack_pointer() as usize;
let instruction_ptr = crash_context.get_instruction_pointer();
let stack_pointer = crash_context.get_stack_pointer();
fill_thread_stack(
config,
buffer,
Expand Down Expand Up @@ -142,7 +142,7 @@ pub fn write(
} else {
MaxStackLen::None // default to no maximum for this thread
};
let instruction_ptr = info.get_instruction_pointer() as usize;
let instruction_ptr = info.get_instruction_pointer();
fill_thread_stack(
config,
buffer,
Expand Down
2 changes: 1 addition & 1 deletion src/mem_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ where
let position = buffer.reserve(size) as u32;

Ok(Self {
position: position as u32,
position,
size,
phantom: std::marker::PhantomData,
})
Expand Down
2 changes: 1 addition & 1 deletion tests/ptrace_dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ fn test_sanitize_stack_copy() {
}

// The instruction pointer definitely should point into an executable mapping.
let instr_ptr = thread_info.get_instruction_pointer() as usize;
let instr_ptr = thread_info.get_instruction_pointer();
let mapping_info = dumper
.find_mapping_no_bias(instr_ptr)
.expect("Failed to find mapping info");
Expand Down