Closed DzenanJupic closed 2 years ago
See https://github.com/rust-lang/backtrace-rs/blob/38cb2d5562a3d1b3a66bc21360d91275ea55cc0a/src/symbolize/mod.rs#L123-L147 1 is substracted from the address as the return address of a call frame is just after the call instruction. We want the information of the call instruction rather than the next instruction.
I see, thank you. It would be great if that could be documented!
Though, when this only applies to the IP of a Frame
, why is this adjustment also used for addresses? Wouldn't it make sense to only apply this in resolve_frame
?
This isn't something that should be worked around, if the ips coming out of this crate don't resolve to the right function that's a bug in this crate. It may be the case that Windows is already doing the subtraction for us to have the reported ip land on the call
instruction instead of the instruction after the call
instruction, unlike libunwind, which would mean that the -1 logic isn't required on Windows. I don't know dbghelp on Windows enough though to know if this is the case.
It would, nevertheless, be great if that could be documented.
It appears, that
resolve
doesn't work correctly on Windows. When resolving function pointer addresses, the resultingSymbol
is incorrect. Everything works fine when callingptr.add(1)
first.Environment
Reproduce
cargo run
: