Skip to content

Commit

Permalink
launchd crashreporter: Handle case where dladdr doesn't succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Jul 25, 2024
1 parent f8ce2be commit 762f42c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions BaseBin/launchdhook/src/crashreporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,18 @@ static void pthread_backtrace(pthread_t pthread, vm_address_t *buffer, unsigned
void crashreporter_dump_backtrace_line(FILE *f, vm_address_t addr)
{
Dl_info info;
dladdr((void *)addr, &info);
if (dladdr((void *)addr, &info) != 0) {
const char *sname = info.dli_sname;
const char *fname = info.dli_fname;
if (!sname) {
sname = "<unexported>";
}

const char *sname = info.dli_sname;
const char *fname = info.dli_fname;
if (!sname) {
sname = "<unexported>";
fprintf(f, "0x%lX: %s (0x%lX + 0x%lX) (%s(0x%lX) + 0x%lX)\n", addr, sname, (vm_address_t)info.dli_saddr, addr - (vm_address_t)info.dli_saddr, fname, (vm_address_t)info.dli_fbase, addr - (vm_address_t)info.dli_fbase);
}
else {
fprintf(f, "0x%lX (no association)\n", addr);
}

fprintf(f, "0x%lX: %s (0x%lX + 0x%lX) (%s(0x%lX) + 0x%lX)\n", addr, sname, (vm_address_t)info.dli_saddr, addr - (vm_address_t)info.dli_saddr, fname, (vm_address_t)info.dli_fbase, addr - (vm_address_t)info.dli_fbase);
}

FILE *crashreporter_open_outfile(const char *source, char **nameOut)
Expand Down

0 comments on commit 762f42c

Please sign in to comment.