You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I've found a bug on my RISCV-64 environment.
I used GCC to build perfetto packages and my target environment uses GNU's libraries such as glibc.
Before copying the stack, the client hooking library tries to get the stack address by using __builtin_frame_address().
In ARM32 and AARCH64, this builtin function works fine so stack unwinding is completed successfully.
But, in RISCV-64, it makes an error due to the difference between calling conventions of architectures.
I've got above codes by using GCC-14 (for RISC-V64) and GCC-9 (for AARCH64).
Both codes are first few lines of RecordMalloc. (in src/profiling/memory/client.cc)
In RISCV-V64, an s0 register (used for the frame pointer) has a caller's stack pointer value while an x29 register (used for the frame pointer in AARCH64) has a modified stack pointer value. So, stack unwinding in RISC-V64 is failed because it tries to get the first return address (stored in sp + 8).
So, I suggest that use the value in the stack pointer register instead of using the frame pointer.
In the process of RecordMalloc, the function anyway reads the registers. So, we can get the stack pointer value easily.
If the compiler provides __builtin_stack_address(), we can use it.
The text was updated successfully, but these errors were encountered:
Thanks for the report. Any RISC-V code in Perfetto is basically totally untested so it's unsurprising that bugs like this exist. We also don't have any capacity to support it given we have no Ci running tests there.
Thanks for the report. Any RISC-V code in Perfetto is basically totally untested so it's unsurprising that bugs like this exist. We also don't have any capacity to support it given we have no Ci running tests there.
Hello. I've found a bug on my RISCV-64 environment.
I used GCC to build perfetto packages and my target environment uses GNU's libraries such as glibc.
Before copying the stack, the client hooking library tries to get the stack address by using
__builtin_frame_address()
.In ARM32 and AARCH64, this builtin function works fine so stack unwinding is completed successfully.
But, in RISCV-64, it makes an error due to the difference between calling conventions of architectures.
See the following assembly codes:
I've got above codes by using GCC-14 (for RISC-V64) and GCC-9 (for AARCH64).
Both codes are first few lines of
RecordMalloc
. (in src/profiling/memory/client.cc)In RISCV-V64, an s0 register (used for the frame pointer) has a caller's stack pointer value while an x29 register (used for the frame pointer in AARCH64) has a modified stack pointer value. So, stack unwinding in RISC-V64 is failed because it tries to get the first return address (stored in sp + 8).
So, I suggest that use the value in the stack pointer register instead of using the frame pointer.
In the process of
RecordMalloc
, the function anyway reads the registers. So, we can get the stack pointer value easily.If the compiler provides
__builtin_stack_address()
, we can use it.The text was updated successfully, but these errors were encountered: