From: Paul Eggert Date: Wed, 21 Dec 2016 17:52:28 +0000 (-0800) Subject: Port dumping better to WSL X-Git-Tag: emacs-26.0.90~1041 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cf6ce9a1fe320ebe5b238af5f7af9416ac954855;p=emacs.git Port dumping better to WSL Problem reported by Angelo Graziosi in: http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00822.html * src/sysdep.c (disable_address_randomization): Detect buggy platforms where 'personality' always returns 0. --- diff --git a/src/sysdep.c b/src/sysdep.c index 96c9e538409..86d420f66c4 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -144,11 +144,16 @@ static const int baud_convert[] = bool disable_address_randomization (void) { - bool disabled = false; int pers = personality (0xffffffff); - disabled = (! (pers & ADDR_NO_RANDOMIZE) - && 0 <= personality (pers | ADDR_NO_RANDOMIZE)); - return disabled; + if (pers < 0) + return false; + int desired_pers = pers | ADDR_NO_RANDOMIZE; + + /* Call 'personality' twice, to detect buggy platforms like WSL + where 'personality' always returns 0. */ + return (pers != desired_pers + && personality (desired_pers) == pers + && personality (0xffffffff) == desired_pers); } #endif