From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Fabrice Popineau Newsgroups: gmane.emacs.devel Subject: Re: Building Emacs on WSL Date: Tue, 20 Dec 2016 21:03:35 +0100 Message-ID: References: <4829e397-ac70-ab22-9c01-848ae876db46@alice.it> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1146977045e9be05441c89e9 X-Trace: blaine.gmane.org 1482264654 3820 195.159.176.226 (20 Dec 2016 20:10:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 20 Dec 2016 20:10:54 +0000 (UTC) Cc: Emacs developers , Angelo Graziosi To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 20 21:10:49 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJQkJ-0008B6-TJ for ged-emacs-devel@m.gmane.org; Tue, 20 Dec 2016 21:10:48 +0100 Original-Received: from localhost ([::1]:53295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJQkM-0001mK-F3 for ged-emacs-devel@m.gmane.org; Tue, 20 Dec 2016 15:10:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJQk9-0001jX-J3 for emacs-devel@gnu.org; Tue, 20 Dec 2016 15:10:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJQk5-0004UZ-Cg for emacs-devel@gnu.org; Tue, 20 Dec 2016 15:10:37 -0500 Original-Received: from smtp2.supelec.fr ([160.228.120.31]:51398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJQk4-0004Ss-SK for emacs-devel@gnu.org; Tue, 20 Dec 2016 15:10:33 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by smtp2.supelec.fr (Postfix) with ESMTP id 0E5898021E for ; Tue, 20 Dec 2016 21:10:31 +0100 (CET) X-Virus-Scanned: amavisd-new at smtp2.supelec.fr Original-Received: from smtp2.supelec.fr ([127.0.0.1]) by localhost (smtp2.supelec.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wvHyvaDm26ke for ; Tue, 20 Dec 2016 21:10:30 +0100 (CET) Original-Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by smtp2.supelec.fr (Postfix) with ESMTPSA id 6A25080218 for ; Tue, 20 Dec 2016 21:10:29 +0100 (CET) Original-Received: by mail-wm0-f49.google.com with SMTP id a197so130263576wmd.0 for ; Tue, 20 Dec 2016 12:10:29 -0800 (PST) X-Gm-Message-State: AIkVDXLOJ+WTUTh+HcLk/RXgvLU6u1VJA87I34ib5AbXhZGMnysHbJUMqtYMO6X9ZNaX4Z4rvYd1LPqN3Mj+8g== X-Received: by 10.28.213.74 with SMTP id m71mr3432625wmg.39.1482264236384; Tue, 20 Dec 2016 12:03:56 -0800 (PST) Original-Received: by 10.28.153.205 with HTTP; Tue, 20 Dec 2016 12:03:35 -0800 (PST) In-Reply-To: X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 160.228.120.31 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210673 Archived-At: --001a1146977045e9be05441c89e9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks Paul for taking care of this. 2016-12-20 20:35 GMT+01:00 Paul Eggert : > On 12/20/2016 04:40 AM, Fabrice Popineau wrote: > >> >> (gdb) run --batch --load loadup bootstrap >> Starting program: /mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs >> --batch --load loadup bootstrap >> warning: Error disabling address space randomization: Succ=C3=A8s >> > > This is a warning from GDB, not from Emacs. GDB normally attempts to > disable ASLR, to make debugging easier. Looking at the sequence of system > calls in GDB 7.12, GDB calls 'personality' in some funky and undocumented > ways, e.g., GDB assumes that errno is not changed when 'personality' > succeeds. > > Please compile and run the attached program under WSL, using the same > flags you use to compile Emacs, and let me know what it does. On Fedora 2= 4 > x86-64, this program outputs: > > personality (0xffffffff) returns 0x0, errno=3D0 (Success) > ADDR_NO_RANDOMIZE was clear > personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=3D0 (Success) > ADDR_NO_RANDOMIZE set successfully > > I get the very same result here : fabrice@LOBSANG:/tmp$ ./personality personality (0xffffffff) returns 0x0, errno=3D0 (Success) ADDR_NO_RANDOMIZE was clear personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=3D0 (Success) ADDR_NO_RANDOMIZE set successfully fabrice@LOBSANG:/tmp$ When run under GDB, the same program outputs: > > personality (0xffffffff) returns 0x40000, errno=3D0 (Success) > ADDR_NO_RANDOMIZE was set > > because GDB already disabled ASLR. You can look at GDB's file > gdb/nat/linux-personality.c to see how GDB differs from Emacs in this are= a; > perhaps there's something there that Emacs can use to figure out that it = is > running with a buggy kernel. > > It seems it does not run the same way here: fabrice@LOBSANG:/tmp$ gdb personality GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from personality...done. (gdb) run Starting program: /tmp/personality warning: Error disabling address space randomization: Succ=C3=A8s warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1: Appel syst=C3=A8me interrompu [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". personality (0xffffffff) returns 0x0, errno=3D0 (Success) ADDR_NO_RANDOMIZE was clear personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=3D0 (Success) ADDR_NO_RANDOMIZE set successfully[Inferior 1 (process 19137) exited normally] >> there is a simple fix: >> > > That fix cannot be installed as-is since ASLR needs to be disabled on > ordinary GNU/Linux platforms. It appears that WSL pretends to support the > Linux 'personality' system call and its ADDR_NO_RANDOMIZE flag, and that > this support does not actually work and makes Emacs crash. > That looks like it. I surely don't expect my "fix" to be included in master. It is only a quick way to make emacs master run under WSL for those who want to test it. WSL (IMHO) is still a work in progress. Once Ubuntu 16.04 will be available, maybe we should consider it more seriously. And even with 16.04, I wonder if it can compete with MSYS2/MinGW64. It needs to be rock solid for that. I am worried by the fact that neither SBCL nor CCL (Common Lisp) run under WSL and for a reason that maybe related to the same topic. Regards, Fabrice --=20 Fabrice Popineau ----------------------------- CentraleSupelec D=C3=A9partement Informatique 3, rue Joliot Curie 91192 Gif/Yvette Cedex Tel direct : +33 (0) 169851950 Standard : +33 (0) 169851212 ------------------------------ --001a1146977045e9be05441c89e9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Paul for taking care of this.


2016-12-20 20:35 GMT+01:= 00 Paul Eggert <eggert@cs.ucla.edu>:
On 12/20/2016 04:40= AM, Fabrice Popineau wrote:

(gdb) run=C2=A0 --batch=C2=A0 --load loadup bootstrap
Starting program: /mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs --= batch=C2=A0 --load loadup bootstrap
warning: Error disabling address space randomization: Succ=C3=A8s

This is a warning from GDB, not from Emacs. GDB normally attempts to disabl= e ASLR, to make debugging easier. Looking at the sequence of system calls i= n GDB 7.12, GDB calls 'personality' in some funky and undocumented = ways, e.g., GDB assumes that errno is not changed when 'personality'= ; succeeds.

Please compile and run the attached program under WSL, using the same flags= you use to compile Emacs, and let me know what it does. On Fedora 24 x86-6= 4, this program outputs:

personality (0xffffffff) returns 0x0, errno=3D0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=3D0 (Success)
ADDR_NO_RANDOMIZE set successfully


I get the very same result here :

fabrice@LOBSANG:/tmp$ ./personality
pers= onality (0xffffffff) returns 0x0, errno=3D0 (Success)
ADDR_NO_RAN= DOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0= x0, errno=3D0 (Success)
ADDR_NO_RANDOMIZE set successfully=C2=A0<= /div>
fabrice@LOBSANG:/tmp$

When run under GDB, the same program outputs:

personality (0xffffffff) returns 0x40000, errno=3D0 (Success)
ADDR_NO_RANDOMIZE was set

because GDB already disabled ASLR. You can look at GDB's file gdb/nat/l= inux-personality.c to see how GDB differs from Emacs in this area; perhaps = there's something there that Emacs can use to figure out that it is run= ning with a buggy kernel.

It seems it does not run the same way here:

fabrice@LOBSANG:/tmp$ gdb personality
GNU = gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free= Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or l= ater <http://gnu.org/licens= es/gpl.html>
This is free software: you are free to change= and redistribute it.
There is NO WARRANTY, to the extent permitt= ed by law.=C2=A0 Type "show copying"
and "show war= ranty" for details.
This GDB was configured as "x86_64-= linux-gnu".
Type "show configuration" for configur= ation details.
For bug reporting instructions, please see:
<= div><http://www.gnu.or= g/software/gdb/bugs/>.
Find the GDB manual and other docum= entation resources online at:
warning: linux_ptrace_test_= ret_to_nx: PTRACE_KILL waitpid returned -1: Appel syst=C3=A8me interrompu
[Thread debugging using libthread_db enabled]
Using host= libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".<= /div>
personality (0xffffffff) returns 0x0, errno=3D0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOM= IZE) returns 0x0, errno=3D0 (Success)
ADDR_NO_RANDOMIZE set succe= ssfully[Inferior 1 (process 19137) exited normally]=C2=A0


there is a simple fix:

That fix cannot be installed as-is since ASLR needs to be disabled on ordin= ary GNU/Linux platforms. It appears that WSL pretends to support the Linux = 'personality' system call and its ADDR_NO_RANDOMIZE flag, and that = this support does not actually work and makes Emacs crash.
=

That looks like it.
I surely don't expect= my "fix" to be included in master.=C2=A0
It is only a = quick way to make emacs master run under WSL for those who want to test it.=
WSL (IMHO) is still a work in progress.=C2=A0
Once Ubu= ntu 16.04 will be available, maybe we should consider it more seriously.
And even with 16.04, I wonder if it can compete with MSYS2/MinGW64.= =C2=A0
It needs to be rock solid for that.
I am worried= by the fact that neither SBCL nor CCL (Common Lisp) run under WSL
and for a reason that maybe related to the same topic.

Regards,

Fabrice


--
Fabrice Popineau
-----------------------------
CentraleSupelec
D=C3=A9partement In= formatique
3, rue Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : +33 (0) 169851950
Standard : +33 (0) 169851212
-= -----------------------------

--001a1146977045e9be05441c89e9--