From: Ivan Maidanski Date: Tue, 26 Sep 2017 21:56:14 +0000 (+0300) Subject: Fix get_maps on proc maps file asynchronous growth X-Git-Tag: v7.4.6~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a49b2ab3f51da89a85ea03e0f71fa1ad0940b71;p=gc Fix get_maps on proc maps file asynchronous growth Issue #179 (bdwgc). Asynchronous growth of /proc/self/maps could be caused by some thread which is not currently registered (e.g. stack allocation on thread creation or a non-GC heap allocation from an unregistered thread). * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Refine comment. * os_dep.c [NEED_PROC_MAPS && THREADS] (GC_get_maps): Replace ABORT with WARN call; refine printed message; add comment. --- diff --git a/os_dep.c b/os_dep.c index 68140027..5d88a499 100644 --- a/os_dep.c +++ b/os_dep.c @@ -178,9 +178,8 @@ GC_INNER char * GC_get_maps(void) /* stacks. And there is no easy way to read the entire */ /* file atomically. This is arguably a misfeature of the */ /* /proc/.../maps interface. */ - - /* Since we don't believe the file can grow */ - /* asynchronously, it should suffice to first determine */ + /* Since we expect the file can grow asynchronously in rare */ + /* cases, it should suffice to first determine */ /* the size (using lseek or read), and then to reread the */ /* file. If the size is inconsistent we have to retry. */ /* This only matters with threads enabled, and if we use */ @@ -230,10 +229,9 @@ GC_INNER char * GC_get_maps(void) return 0; # ifdef THREADS if (maps_size > old_maps_size) { - ABORT_ARG2("Unexpected asynchronous /proc/self/maps growth " - "(unregistered thread?)", " from %lu to %lu", - (unsigned long)old_maps_size, - (unsigned long)maps_size); + /* This might be caused by e.g. thread creation. */ + WARN("Unexpected asynchronous /proc/self/maps growth" + " (to %" WARN_PRIdPTR " bytes)\n", maps_size); } # endif } while (maps_size >= maps_buf_sz || maps_size < old_maps_size);