Don't output memory map in crash report for ASAN

ASAN maps a large amount of memory, which makes the memory map section
massive.
This commit is contained in:
Peter Zhu 2024-12-11 14:27:10 -05:00
parent ca2d19d4e5
commit 2da70aac25
Notes: git 2024-12-12 19:08:14 +00:00

View File

@ -1212,7 +1212,8 @@ rb_vm_bugreport(const void *ctx, FILE *errout)
} }
{ {
#ifdef PROC_MAPS_NAME #ifndef RUBY_ASAN_ENABLED
# ifdef PROC_MAPS_NAME
{ {
FILE *fp = fopen(PROC_MAPS_NAME, "r"); FILE *fp = fopen(PROC_MAPS_NAME, "r");
if (fp) { if (fp) {
@ -1229,8 +1230,8 @@ rb_vm_bugreport(const void *ctx, FILE *errout)
kprintf("\n\n"); kprintf("\n\n");
} }
} }
#endif /* __linux__ */ # endif /* __linux__ */
#ifdef HAVE_LIBPROCSTAT # ifdef HAVE_LIBPROCSTAT
# define MIB_KERN_PROC_PID_LEN 4 # define MIB_KERN_PROC_PID_LEN 4
int mib[MIB_KERN_PROC_PID_LEN]; int mib[MIB_KERN_PROC_PID_LEN];
struct kinfo_proc kp; struct kinfo_proc kp;
@ -1249,8 +1250,8 @@ rb_vm_bugreport(const void *ctx, FILE *errout)
procstat_close(prstat); procstat_close(prstat);
kprintf("\n"); kprintf("\n");
} }
#endif /* __FreeBSD__ */ # endif /* __FreeBSD__ */
#ifdef __APPLE__ # ifdef __APPLE__
vm_address_t addr = 0; vm_address_t addr = 0;
vm_size_t size = 0; vm_size_t size = 0;
struct vm_region_submap_info map; struct vm_region_submap_info map;
@ -1273,18 +1274,19 @@ rb_vm_bugreport(const void *ctx, FILE *errout)
((map.protection & VM_PROT_READ) != 0 ? "r" : "-"), ((map.protection & VM_PROT_READ) != 0 ? "r" : "-"),
((map.protection & VM_PROT_WRITE) != 0 ? "w" : "-"), ((map.protection & VM_PROT_WRITE) != 0 ? "w" : "-"),
((map.protection & VM_PROT_EXECUTE) != 0 ? "x" : "-")); ((map.protection & VM_PROT_EXECUTE) != 0 ? "x" : "-"));
#ifdef HAVE_LIBPROC_H # ifdef HAVE_LIBPROC_H
char buff[PATH_MAX]; char buff[PATH_MAX];
if (proc_regionfilename(getpid(), addr, buff, sizeof(buff)) > 0) { if (proc_regionfilename(getpid(), addr, buff, sizeof(buff)) > 0) {
kprintf(" %s", buff); kprintf(" %s", buff);
} }
#endif # endif
kprintf("\n"); kprintf("\n");
} }
addr += size; addr += size;
size = 0; size = 0;
} }
# endif
#endif #endif
} }
return true; return true;