From cf6ce9a1fe320ebe5b238af5f7af9416ac954855 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 21 Dec 2016 09:52:28 -0800 Subject: [PATCH] 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. --- src/sysdep.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 -- 2.39.2