-
Notifications
You must be signed in to change notification settings - Fork 53
Description
I have a repo I'm attempting to profile with these instructions: https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html#profiling-the-compiler
cargo +nightly rustc --lib -- -Zself-profile -Zself-profile-events=default,args
This results in the following output:
thread 'rustc' panicked at /rust/deps/measureme-10.1.1/src/stringtable.rs:105:62:
called `Option::unwrap()` on a `None`
Which appears to be the unwrap
within:
measureme/measureme/src/stringtable.rs
Lines 103 to 107 in 6b8bc6d
#[inline] | |
pub fn from_addr(addr: Addr) -> StringId { | |
let id = addr.0.checked_add(FIRST_REGULAR_STRING_ID).unwrap(); | |
StringId::new(id) | |
} |
I noticed that the type of StringId
is a u32
:
measureme/measureme/src/stringtable.rs
Line 77 in 6b8bc6d
pub struct StringId(u32); |
And since we're calling from_addr
, we care about that type too:
measureme/measureme/src/serialization.rs
Lines 65 to 73 in 306a7d2
/// An address within a data stream. Each data stream has its own address space, | |
/// i.e. the first piece of data written to the events stream will have | |
/// `Addr(0)` and the first piece of data written to the string data stream | |
/// will *also* have `Addr(0)`. | |
// | |
// TODO: Evaluate if it makes sense to add a type tag to `Addr` in order to | |
// prevent accidental use of `Addr` values with the wrong address space. | |
#[derive(Clone, Copy, Eq, PartialEq, Debug)] | |
pub struct Addr(pub u32); |
Why do we believe this will be limited to u32? As a small data point, the "...mm_profdata" file I was emitting looks like it's just over 4 GiB in size, which sorta aligns with the idea of a u32 overflow.