Skip to content

unw_backtrace() returns wrong addresses #94

Closed
@perfhunter

Description

@perfhunter

I have unw_backtrace() on x86-64 machine always returning addresses that are off by one relative to the instruction address after the call. This issue is related to fast backtrace optimization and I guess it may be caused by not restoring rip after decrementing it by use_prev_instr flag. Indeed, in src/x86_64/Gtrace.c we have:
line 438: rip -= d->use_prev_instr;
and before finishing the loop iteration:
line 543: buffer[depth++] = (void *) (rip - d->use_prev_instr);
I see no place where rip gets incremented again in this loop, so at least for standard frames we definitely write to the buffer the wrong value.
There is no problem if I manually unwind the stack using unw_step().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions