Skip to content

Commit 2315584

Browse files
authored
Mask out non-version value for version comparison (#59)
* Mask out non-version value for version comparison Fixes the indexed profile parsing * Update changelog
1 parent f355495 commit 2315584

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Basic MC/DC parsing in object files
1010
- llvm 21 into tests
1111

12+
### Fixed
13+
- Non-version number flags in version field weren't masked out when using version for indexed profile parsing of causing parse errors.
14+
1215
## [0.8.3]
1316
### Changed
1417
- Saturating operations on expression adding/subtracting to avoid panics

src/instrumentation_profile/indexed_profile.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,29 @@ impl InstrProfReader for IndexedInstrProf {
223223
error,
224224
))
225225
})?;
226+
let version_num = version & !VARIANT_MASKS_ALL;
226227
let (bytes, hash_offset) = le_u64(bytes)?;
227-
let (bytes, mem_prof_offset) = if version >= 8 {
228+
let (bytes, mem_prof_offset) = if version_num >= 8 {
228229
let (bytes, offset) = le_u64(bytes)?;
229230
(bytes, Some(offset))
230231
} else {
231232
(bytes, None)
232233
};
233-
let (bytes, binary_id_offset) = if version >= 9 {
234+
let (bytes, binary_id_offset) = if version_num >= 9 {
234235
let (bytes, offset) = le_u64(bytes)?;
235236
(bytes, Some(offset))
236237
} else {
237238
(bytes, None)
238239
};
239240

240-
let (bytes, vtable_offset) = if version >= 12 {
241+
let (bytes, vtable_offset) = if version_num >= 12 {
241242
let (bytes, offset) = le_u64(bytes)?;
242243
(bytes, Some(offset))
243244
} else {
244245
(bytes, None)
245246
};
246247

247-
let (bytes, temporary_prof_traces_offset) = if version >= 10 {
248+
let (bytes, temporary_prof_traces_offset) = if version_num >= 10 {
248249
let (bytes, offset) = le_u64(bytes)?;
249250
(bytes, Some(offset))
250251
} else {

0 commit comments

Comments
 (0)