Skip to content

Commit

Permalink
Merge pull request #9876 from brminich/ucm/fix_remap_error
Browse files Browse the repository at this point in the history
UCM: Print errno when mremap fails
  • Loading branch information
yosefe committed May 16, 2024
2 parents 5242171 + 6a3923e commit 7f30f89
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ucm/util/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void ucm_parse_proc_self_maps(ucm_proc_maps_cb_t cb, void *arg)
char prot_c[4];
int line_num;
int prot;
char *ptr, *newline;
char *ptr, *newline, *orig_buffer;
int maps_fd;
int ret;
int n;
Expand Down Expand Up @@ -188,10 +188,13 @@ void ucm_parse_proc_self_maps(ucm_proc_maps_cb_t cb, void *arg)
}
} else if (read_size == buffer_size - offset) {
/* enlarge buffer */
buffer = ucm_orig_mremap(buffer, buffer_size, buffer_size * 2,
MREMAP_MAYMOVE, NULL);
orig_buffer = buffer;
buffer = ucm_orig_mremap(buffer, buffer_size, buffer_size * 2,
MREMAP_MAYMOVE, NULL);
if (buffer == MAP_FAILED) {
ucm_fatal("failed to allocate maps buffer(size=%zu)", buffer_size);
ucm_fatal("failed to reallocate buffer for reading "
"/proc/self/maps from %p/%zu to size %zu: %m",
orig_buffer, buffer_size, buffer_size * 2);
}
buffer_size *= 2;

Expand Down

0 comments on commit 7f30f89

Please sign in to comment.