Subject: bug#33174: 27.0.50; Dump fails on GNU/Linux ppc64le

From: Thomas Fitzsimmons <[email-masked]>
Date: Sun, 28 Oct 2018 21:47:06 -0400

Paul Eggert <[email-masked]> writes:

> Wonderful. Yet another reason we need to get the pdumper branch working. Anyway:
>
> 1. Can you use strace and/or GDB to investigate how ./temacs is
> disabling address randomization? In the emacs-26 branch, if you run
> this command in src:
>
> strace -f -o /tmp/tr ./temacs --batch  --load loadup bootstrap
>
> the output file /tmp/tr should contain something like this:
>
> 18406 personality(0xffffffff)           = 0 (PER_LINUX)
> 18406 personality(PER_LINUX|ADDR_NO_RANDOMIZE) = 0 (PER_LINUX)
> 18406 personality(0xffffffff)           = 0x40000 (PER_LINUX|ADDR_NO_RANDOMIZE)

I see the above personality calls exactly as you've shown them.

strace never gets to the next execve; the crash happens before the next
execve is run, see below.

> 18406 execve("./temacs", ["./temacs", "--batch", "--load", "loadup",
> "bootstrap"], 0xc521b0 /* 80 vars */) = 0
>
> and later on there should be one more call to 'personality', like this:
>
> 18406 personality(0xffffffff)           = 0x40000 (PER_LINUX|ADDR_NO_RANDOMIZE)
>
> If it doesn't look like this, please investigate why, by using GDB.

When I run the command under gdb, it succeeds, so I had to enable core
dumps to get the backtrace:

$ gdb ./temacs core
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "powerpc64le-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./temacs...done.
[New LWP 26831]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
Core was generated by `./temacs --batch --load loadup bootstrap '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __memcpy_power7 () at ../sysdeps/powerpc/powerpc64/power7/memcpy.S:111
111	../sysdeps/powerpc/powerpc64/power7/memcpy.S: No such file or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
DISPLAY = :0
TERM = dumb
Breakpoint 1 at 0x10118108: file emacs.c, line 363.
Temporary breakpoint 2 at 0x10137aa8: init_sys_modes. (3 locations)
(gdb) thread apply all bt

Thread 1 (Thread 0x7fff940a7be0 (LWP 26831)):
#0  __memcpy_power7 () at ../sysdeps/powerpc/powerpc64/power7/memcpy.S:111
#1  0x00000000101ec188 in memcpy (__len=383855080, __src=0x105cd618, __dest=<optimized out>) at /usr/include/powerpc64le-linux-gnu/bits/string3.h:53
#2  unexec (new_name=0x11b934f8 <bss_sbrk_buffer+22229000> "/build/emacs/src/emacs", 
    old_name=0x11b93528 <bss_sbrk_buffer+22229048> "/build/emacs/src/temacs") at unexelf.c:411
#3  0x0000000010110bec in Fdump_emacs (filename=XIL(0x11b945a4), symfile=XIL(0x11b94584)) at emacs.c:2224
#4  0x00000000101a7cb8 in eval_sub (form=...) at eval.c:2244
#5  0x00000000101a8194 in Fprogn (body=XIL(0x107360d3)) at eval.c:459
#6  0x00000000101a7d6c in eval_sub (form=...) at eval.c:2193
#7  0x00000000101ab8bc in Fif (args=...) at eval.c:414
#8  0x00000000101a7d6c in eval_sub (form=...) at eval.c:2193
#9  0x00000000101d8a98 in readevalloop (readcharfun=XIL(0x68d0), infile0=0x7fffc3cef950, sourcename=XIL(0x107216a4), printflag=false, unibyte=..., 
    readfun=XIL(0), start=XIL(0), end=XIL(0)) at lread.c:2048
#10 0x00000000101d90bc in Fload (file=XIL(0x107215a4), noerror=..., nomessage=XIL(0), nosuffix=..., must_suffix=...) at lread.c:1435
#11 0x00000000101a7c34 in eval_sub (form=...) at eval.c:2255
#12 0x00000000101acd18 in Feval (form=XIL(0x10727f03), lexical=...) at eval.c:2061
#13 0x00000000101188f8 in top_level_2 () at keyboard.c:1119
#14 0x00000000101a6410 in internal_condition_case (bfun=0x101188d0 <top_level_2>, handlers=..., hfun=0x1011f030 <cmd_error>) at eval.c:1336
#15 0x00000000101188a8 in top_level_1 (ignore=...) at keyboard.c:1127
#16 0x00000000101a6364 in internal_catch (tag=..., func=0x10118800 <top_level_1>, arg=XIL(0)) at eval.c:1101
#17 0x000000001011873c in command_loop () at keyboard.c:1088
#18 0x000000001011e89c in recursive_edit_1 () at keyboard.c:695
#19 0x000000001011eeb4 in Frecursive_edit () at keyboard.c:766
#20 0x0000000010017804 in main (argc=<optimized out>, argv=0x7fffc3cf0308) at emacs.c:1717
You can't do that without a process to debug.
(gdb) 

> 2. What filesystem are you building in,

ext4

> and does it support xattrs?

Yes.

> What is the output of the following in your build directory?
>
>     touch x
>     setfattr -n user.variable -v value x
>     getfattr -n user.variable x

I bootstrapped Debian from a minimal root file system, so I didn't have
the attr package installed (i.e., the setfattr and getfattr commands
were not found).  After I installed it, the output of the above commands
is:

$ touch x
$ setfattr -n user.variable -v value x
$ getfattr -n user.variable x
# file: x
user.variable="value"

> 3. What is the output of "getfattr -d src/temacs"? It should be something like this:
>
> # file: src/temacs
> user.pax.flags="er"
>
> If not, we need to figure out why not.

Yes, after I re-ran configure and make after having installed the attr
package:

$ getfattr -d src/temacs
# file: src/temacs
user.pax.flags="er"

> 4. The output of 'make V=1' should contain something like the
> following. If not, please investigate why not.
>
> setfattr -n user.pax.flags -v er temacs

When setfattr is not installed, configure shows:

[...]
checking for setfattr... no
[...]

and that command is not run.  After I installed the attr package,
configure shows:

checking for setfattr... yes

and the above command shows up in make V=1 output.

Thomas