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

[Backtracing][Linux] Disable invoking process_vm_readv() for older Android APIs #67478

Merged
merged 1 commit into from Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions stdlib/public/runtime/CrashHandlerLinux.cpp
Expand Up @@ -660,9 +660,13 @@ memserver_fault(int sig) {
ssize_t __attribute__((noinline))
memserver_read(void *to, const void *from, size_t len) {
if (memserver_has_ptrace) {
// This won't run for older Android APIs anyway, but it can't be compiled
// either, as process_vm_readv() isn't available.
#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 23)
struct iovec local = { to, len };
struct iovec remote = { const_cast<void *>(from), len };
return process_vm_readv(memserver_pid, &local, 1, &remote, 1, 0);
#endif
} else {
if (!sigsetjmp(memserver_fault_buf, 1)) {
memcpy(to, from, len);
Expand All @@ -682,7 +686,12 @@ memserver_entry(void *dummy __attribute__((unused))) {
prctl(PR_SET_NAME, "[backtrace]");
#endif

// process_vm_readv() is not available for older Android APIs.
#if defined(__ANDROID_API__) && __ANDROID_API__ < 23
memserver_has_ptrace = false;
#else
memserver_has_ptrace = !!prctl(PR_CAPBSET_READ, CAP_SYS_PTRACE);
#endif

if (!memserver_has_ptrace) {
struct sigaction sa;
Expand Down