From 45d03965838b52dad80a936543ce4ba0579b4f93 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Tue, 3 Feb 2026 18:13:46 +0100 Subject: [PATCH 1/4] Failing test --- symbolic-symcache/src/raw.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/symbolic-symcache/src/raw.rs b/symbolic-symcache/src/raw.rs index 1d29cd87c..21e0a8738 100644 --- a/symbolic-symcache/src/raw.rs +++ b/symbolic-symcache/src/raw.rs @@ -142,4 +142,17 @@ mod tests { assert_eq!(mem::size_of::(), 4); assert_eq!(mem::align_of::(), 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; + } } From 3e1ee123b9d8046d7d2e8a7471059f1577d1a787 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Tue, 3 Feb 2026 18:21:29 +0100 Subject: [PATCH 2/4] Fix --- symbolic-symcache/src/lib.rs | 2 +- symbolic-symcache/src/raw.rs | 7 +++++-- symbolic-symcache/src/writer.rs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/symbolic-symcache/src/lib.rs b/symbolic-symcache/src/lib.rs index d0d9f7b1d..714475529 100644 --- a/symbolic-symcache/src/lib.rs +++ b/symbolic-symcache/src/lib.rs @@ -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. diff --git a/symbolic-symcache/src/raw.rs b/symbolic-symcache/src/raw.rs index 21e0a8738..88764aa1b 100644 --- a/symbolic-symcache/src/raw.rs +++ b/symbolic-symcache/src/raw.rs @@ -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"; @@ -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, + /// + /// 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, diff --git a/symbolic-symcache/src/writer.rs b/symbolic-symcache/src/writer.rs index 728f95e1e..ed79341fd 100644 --- a/symbolic-symcache/src/writer.rs +++ b/symbolic-symcache/src/writer.rs @@ -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, From 3856c6794402179f03d99825c01ffed9b1f03f90 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Tue, 3 Feb 2026 18:46:12 +0100 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f60d97ee2..e8a44e44e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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** From 0b844d31803762e09f1719c87d5c892bbe381c29 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Tue, 3 Feb 2026 18:49:20 +0100 Subject: [PATCH 4/4] Fix debug impl --- symbolic-symcache/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbolic-symcache/src/lib.rs b/symbolic-symcache/src/lib.rs index 714475529..9eea45866 100644 --- a/symbolic-symcache/src/lib.rs +++ b/symbolic-symcache/src/lib.rs @@ -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)