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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Fixes**

- symcache: Fixed an unsound implementation of `Pod` ([#958](https://github.com/getsentry/symbolic/pull/958))

## 12.17.1

**Fixes**
Expand Down
4 changes: 2 additions & 2 deletions symbolic-symcache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl std::fmt::Debug for SymCache<'_> {
f.debug_struct("SymCache")
.field("version", &self.header.version)
.field("debug_id", &self.header.debug_id)
.field("arch", &self.header.arch)
.field("arch", &Arch::from_u32(self.header.arch))
.field("files", &self.header.num_files)
.field("functions", &self.header.num_functions)
.field("source_locations", &self.header.num_source_locations)
Expand Down Expand Up @@ -256,7 +256,7 @@ impl<'data> SymCache<'data> {

/// The architecture of the symbol file.
pub fn arch(&self) -> Arch {
self.header.arch
Arch::from_u32(self.header.arch)
}

/// The debug identifier of the cache file.
Expand Down
20 changes: 18 additions & 2 deletions symbolic-symcache/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use watto::Pod;

use symbolic_common::{Arch, DebugId};
use symbolic_common::DebugId;

/// The magic file preamble as individual bytes.
const SYMCACHE_MAGIC_BYTES: [u8; 4] = *b"SYMC";
Expand Down Expand Up @@ -37,7 +37,10 @@ pub(crate) struct Header {
/// Debug identifier of the object file.
pub(crate) debug_id: DebugId,
/// CPU architecture of the object file.
pub(crate) arch: Arch,
///
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
///

/// This cannot be [`symbolic_common::Arch`] because
/// not every bit pattern is valid for that type.
pub(crate) arch: u32,

/// Number of included [`File`]s.
pub(crate) num_files: u32,
Expand Down Expand Up @@ -142,4 +145,17 @@ mod tests {
assert_eq!(mem::size_of::<Range>(), 4);
assert_eq!(mem::align_of::<Range>(), 4);
}

#[test]
fn test_header_arch_from_bytes() {
// Create an array of `u32`s and later transmute it to a slice of `u8`.
// This is to get a `u8` slice which is 4-byte aligned.
let mut nums = [0u32; 20];
// There are 40B, or 10 `u32`, before `arch` in the header.
nums[10] = 17;
let ptr = &raw const nums as *const u8;
let bytes: &[u8] = unsafe { std::slice::from_raw_parts(ptr, 80) };

let _arch = Header::ref_from_bytes(bytes).unwrap().arch;
}
}
2 changes: 1 addition & 1 deletion symbolic-symcache/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl<'a> SymCacheConverter<'a> {
version: crate::SYMCACHE_VERSION,

debug_id: self.debug_id,
arch: self.arch,
arch: self.arch as u32,

num_files,
num_functions,
Expand Down
Loading