From eba63329da6ccb3bd1f2293affd655575a688c59 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 4 May 2018 11:15:55 +0300 Subject: [PATCH] Really abort if failed to read /proc for library registration (Linux) * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Change return type from word to void; remove "return 1". * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_dynamic_libraries): Call ABORT() if GC_get_maps() returned null. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Remove outdated comment (about fn). --- dyn_load.c | 11 +++++++---- os_dep.c | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dyn_load.c b/dyn_load.c index 9320adb..21188f7 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -309,7 +309,7 @@ static void sort_heap_sects(struct HeapSect *base, size_t number_of_elements) } } -STATIC word GC_register_map_entries(char *maps) +STATIC void GC_register_map_entries(char *maps) { char *prot; char *buf_ptr = maps; @@ -327,7 +327,8 @@ STATIC word GC_register_map_entries(char *maps) for (;;) { buf_ptr = GC_parse_map_entry(buf_ptr, &start, &end, &prot, &maj_dev, 0); - if (buf_ptr == NULL) return 1; + if (NULL == buf_ptr) + break; if (prot[1] == 'w') { /* This is a writable mapping. Add it to */ /* the root set unless it is already otherwise */ @@ -394,13 +395,15 @@ STATIC word GC_register_map_entries(char *maps) GC_add_roots_inner((char *)start, (char *)end, TRUE); } } - return 1; } GC_INNER void GC_register_dynamic_libraries(void) { - if (!GC_register_map_entries(GC_get_maps())) + char *maps = GC_get_maps(); + + if (NULL == maps) ABORT("Failed to read /proc for library registration"); + GC_register_map_entries(maps); } /* We now take care of the main data segment ourselves: */ diff --git a/os_dep.c b/os_dep.c index cbccfbd..8e7e67f 100644 --- a/os_dep.c +++ b/os_dep.c @@ -245,8 +245,6 @@ GC_INNER char * GC_get_maps(void) } while (maps_size >= maps_buf_sz || maps_size < old_maps_size); /* In the single-threaded case, the second clause is false. */ maps_buf[maps_size] = '\0'; - - /* Apply fn to result. */ return maps_buf; } -- 2.7.4