Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about "fix lr causes the call stack inaccurate" #330

Open
ZhiyuWong opened this issue May 21, 2019 · 2 comments
Open

about "fix lr causes the call stack inaccurate" #330

ZhiyuWong opened this issue May 21, 2019 · 2 comments

Comments

@ZhiyuWong
Copy link
Collaborator

ZhiyuWong commented May 21, 2019

#327 Stop collect link register may cause the lack of second frame of backtrace.

The Procedure Call Standard for the ARM 64-bit Architecture indicate that lr stored

sequentially next value of program counter—the return address

so, the instruction before address stored in link register is the call instruction, which is the second frame of backtrace.

5.3 Subroutine Calls
The A64 instruction set contains primitive subroutine call instructions, BL and BLR, which performs a branch-with link operation. The effect of executing BL is to transfer the sequentially next value of the program counter—the return address—into the link register (LR) and the destination address into the program counter. The effect of executing BLR is similar except that the new PC value is read from the specified register.

@ZhiyuWong ZhiyuWong changed the title about: about "fix lr causes the call stack inaccurate" May 21, 2019
@ZhiyuWong
Copy link
Collaborator Author

ZhiyuWong commented May 21, 2019

Here's an example

void test1() {
    char *a = (char *)0x1;
    *a = 1;
}

void test() {
    test1();
}

When we call test() from -[ViewController oneClickCrash:], the process will crash and the crash log is list below
Enable link register collecting:

Thread 0 Crashed:
0   Demo                0x00000001027f56d0 test1 + 20
1   Demo                0x00000001027f56e8 test + 12
2   Demo                0x00000001027f571c -[ViewController oneClickCrash:] + 44
...

Disable link register collecting:

Thread 0 Crashed:
0   Demo                0x000000010224171c test1 + 20
1   Demo                0x0000000102241768 -[ViewController oneClickCrash:] + 44
...

@JunyiXie
Copy link
Contributor

I think
We can't control the behavior of the compiler, we should not consider the case and use the lr register.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants