The ModuleFrameInfo and FunctionInfo data structures maintain
a list of ranges via a BTreeMap. The key to that map is one
past the end of the module/function in question. This causes
a problem in the case of immediately adjacent ranges. For
example, if we have two functions occupying adjacent ranges:
A: 0-100
B: 100-200
function A is stored with a key of 100 and B with a key of 200.
Now, when looking up the function associated with address 100,
we'd expect to find B. However the current code:
let (end, func) = info.functions.range(pc..).next()?;
if pc < func.start || *end < pc {
will look up the value 100 in the map and return function A,
which will then fail the pc < func.start check in the next
line, so the result will be failure.
To fix this problem, make sure that the key used when
registering functions or modules is the address of the
last byte, not one past the end.