frida / frida-gum

Cross-platform instrumentation and introspection library written in C
https://frida.re
Other
753 stars 245 forks source link

`gum_process_enumerate_ranges` is slow when an application is making use of address sanitizer #695

Open WorksButNotTested opened 1 year ago

WorksButNotTested commented 1 year ago

test.cpp

#include "frida-gumjs.h"

gboolean found (const GumRangeDetails * details,
    gpointer user_data)
{
    static int i=0;
    printf("i: %4d 0x%016llx-0x%016llx %s\n", ++i, details->range->base_address, details->range->base_address + details->range->size, details->file == NULL ? "(null)" : details->file->path);
    return TRUE;
}

int main() {
    puts("START");
    gum_init_embedded ();
    gum_process_enumerate_ranges (GUM_PAGE_NO_ACCESS, found, NULL);
    puts("END");
}

build

wget https://github.com/frida/frida/releases/download/16.0.5/frida-gumjs-devkit-16.0.5-macos-x86_64.tar.xz
tar Jxvf frida-gumjs-devkit-16.0.5-macos-x86_64.tar.xz
clang -o ok test.cpp -L . -I . -lfrida-gumjs -lresolv
clang -fsanitize=address -o slow test.cpp -L . -I . -lfrida-gumjs -lresolv

run

./ok
./slow

info

$ sw_vers
ProductName:    macOS
ProductVersion: 12.6.1
BuildVersion:   21G217

$ clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin