Subject: C02cond.ztst segfaults (was: Re: Strange test suite behaviour since zsh 5.2-dev-1: C02cond.ztst no more reports its finishing)
From: Axel Beckert <[email-masked]>
To: [email-masked]
Date: Mon, 1 Feb 2016 00:03:13 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Hi Bart,

[Taking [email-masked] out of the loop for now.]

Bart Schaefer wrote:
> On Jan 31,  9:19pm, Axel Beckert wrote:
> } Any ideas what could cause this silent exiting of a .ztst script and
> } why it only appears under certain (yet not 100% clear) conditions?
> 
> Silent exit occurs when the test crashes the test-harness shell.  This
> is an unfortunate side-effect of the way error output is managed by the
> harness; the only way to detect it is to spot coredump files, or find

Thanks for reminding me of looking for core dumps!

I remembered it right: Building zsh with -fPIE triggered the issue (or
at least a very similar one) also on x86_64. And since I got a
core dump, here's the backtrace:

Core was generated by `../Src/zsh +Z -f ../../Test/ztst.zsh ../../Test/C02cond.ztst'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:30
30      ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: No such file or directory.
(gdb) bt
#0  __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:30
#1  0x000055e7dc4af8f4 in is_cond_binary_op (str=0x7f05376fe238 "non-empty-string") at ../../Src/text.c:63
#2  0x000055e7dc445491 in bin_test (name=0x7f05376fe228 "[", argv=0x7f05376fe260, ops=<optimized out>, func=<optimized out>) at ../../Src/builtin.c:6556
#3  0x000055e7dc4458b8 in execbuiltin (args=args@entry=0x7f05376fe198, assigns=assigns@entry=0x0, bn=bn@entry=0x55e7dc6df160 <builtins+320>) at ../../Src/builtin.c:484
#4  0x000055e7dc45390a in execcmd (state=state@entry=0x7ffcdc3096f0, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=2, last1=<optimized out>) at ../../Src/exec.c:3651
#5  0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc3096f0, pcode=<optimized out>, how=how@entry=2, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#6  0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc3096f0, slcode=<optimized out>, how=how@entry=2, last1=last1@entry=0) at ../../Src/exec.c:1527
#7  0x000055e7dc455eff in execlist (state=state@entry=0x7ffcdc3096f0, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1293
#8  0x000055e7dc4561f0 in execode (p=0x7f05376fda20, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0, context=context@entry=0x55e7dc4c57e8 "eval") at ../../Src/exec.c:1076
#9  0x000055e7dc43c276 in eval (argv=0x7f05376fd250) at ../../Src/builtin.c:5509
#10 0x000055e7dc4458b8 in execbuiltin (args=args@entry=0x7f05376fd148, assigns=assigns@entry=0x0, bn=bn@entry=0x55e7dc6df5e0 <builtins+1472>) at ../../Src/builtin.c:484
#11 0x000055e7dc45390a in execcmd (state=state@entry=0x7ffcdc30b000, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=18, last1=<optimized out>) at ../../Src/exec.c:3651
#12 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc30b000, pcode=<optimized out>, how=how@entry=18, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#13 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc30b000, slcode=<optimized out>, how=how@entry=18, last1=0) at ../../Src/exec.c:1527
#14 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc30b000, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1285
#15 0x000055e7dc4561f0 in execode (p=p@entry=0x7f0537701288, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0, context=context@entry=0x55e7dc4bff74 "shfunc") at ../../Src/exec.c:1076
#16 0x000055e7dc456ecb in runshfunc (prog=0x7f0537701288, wrap=0x0, name=0x7f05376fd028 "(anon)") at ../../Src/exec.c:5368
#17 0x000055e7dc457630 in doshfunc (shfunc=shfunc@entry=0x55e7de4d05a0, doshargs=doshargs@entry=0x7f05377012c0, noreturnval=noreturnval@entry=0) at ../../Src/exec.c:5234
#18 0x000055e7dc4579ff in execshfunc (shf=shf@entry=0x55e7de4d05a0, args=args@entry=0x7f05377012c0) at ../../Src/exec.c:4865
#19 0x000055e7dc4581f3 in execshfunc (args=0x7f05377012c0, shf=0x55e7de4d05a0) at ../../Src/exec.c:4727
#20 execfuncdef (state=state@entry=0x7ffcdc30b950, redir_prog=redir_prog@entry=0x0) at ../../Src/exec.c:4731
#21 0x000055e7dc4584aa in execsimple (state=state@entry=0x7ffcdc30b950) at ../../Src/exec.c:1130
#22 0x000055e7dc455e62 in execlist (state=state@entry=0x7ffcdc30b950, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1283
#23 0x000055e7dc4561f0 in execode (p=p@entry=0x55e7de4cc5e0, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0, context=context@entry=0x55e7dc4bff74 "shfunc") at ../../Src/exec.c:1076
#24 0x000055e7dc456ecb in runshfunc (prog=0x55e7de4cc5e0, wrap=0x0, name=0x7f0537705030 "ZTST_execchunk") at ../../Src/exec.c:5368
#25 0x000055e7dc457630 in doshfunc (shfunc=shfunc@entry=0x55e7de4ccea0, doshargs=doshargs@entry=0x7f0537884ba8, noreturnval=noreturnval@entry=0) at ../../Src/exec.c:5234
#26 0x000055e7dc4579ff in execshfunc (shf=shf@entry=0x55e7de4ccea0, args=args@entry=0x7f0537884ba8) at ../../Src/exec.c:4865
#27 0x000055e7dc45397a in execshfunc (args=0x7f0537884ba8, shf=0x55e7de4ccea0) at ../../Src/exec.c:4831
#28 execcmd (state=state@entry=0x7ffcdc310500, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=2, last1=2) at ../../Src/exec.c:3532
#29 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc310500, pcode=<optimized out>, how=how@entry=2, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#30 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc310500, slcode=<optimized out>, how=how@entry=2, last1=0) at ../../Src/exec.c:1527
#31 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc310500, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1285
#32 0x000055e7dc479e9b in execif (state=0x7ffcdc310500, do_exec=0) at ../../Src/loop.c:565
#33 0x000055e7dc4526bd in execcmd (state=state@entry=0x7ffcdc310500, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=2, last1=2) at ../../Src/exec.c:3480
#34 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc310500, pcode=<optimized out>, how=how@entry=2, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#35 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc310500, slcode=<optimized out>, how=how@entry=2, last1=0) at ../../Src/exec.c:1527
#36 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc310500, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1285
#37 0x000055e7dc479aa7 in execwhile (state=0x7ffcdc310500, do_exec=<optimized out>) at ../../Src/loop.c:452
#38 0x000055e7dc4526bd in execcmd (state=state@entry=0x7ffcdc310500, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=2, last1=2) at ../../Src/exec.c:3480
#39 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc310500, pcode=<optimized out>, how=how@entry=2, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#40 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc310500, slcode=<optimized out>, how=how@entry=2, last1=0) at ../../Src/exec.c:1527
#41 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc310500, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1285
#42 0x000055e7dc4561f0 in execode (p=p@entry=0x55e7de4cd0d0, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0, context=context@entry=0x55e7dc4bff74 "shfunc") at ../../Src/exec.c:1076
#43 0x000055e7dc456ecb in runshfunc (prog=0x55e7de4cd0d0, wrap=0x0, name=0x7f0537884030 "ZTST_test") at ../../Src/exec.c:5368
#44 0x000055e7dc457630 in doshfunc (shfunc=shfunc@entry=0x55e7de4cd7d0, doshargs=doshargs@entry=0x7f0537889560, noreturnval=noreturnval@entry=0) at ../../Src/exec.c:5234
#45 0x000055e7dc4579ff in execshfunc (shf=shf@entry=0x55e7de4cd7d0, args=args@entry=0x7f0537889560) at ../../Src/exec.c:4865
#46 0x000055e7dc45397a in execshfunc (args=0x7f0537889560, shf=0x55e7de4cd7d0) at ../../Src/exec.c:4831
#47 execcmd (state=state@entry=0x7ffcdc3150f0, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=2, last1=2) at ../../Src/exec.c:3532
#48 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc3150f0, pcode=<optimized out>, how=how@entry=2, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#49 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc3150f0, slcode=<optimized out>, how=how@entry=2, last1=0) at ../../Src/exec.c:1527
#50 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc3150f0, dont_change_job=dont_change_job@entry=1, exiting=0) at ../../Src/exec.c:1285
#51 0x000055e7dc47a184 in execcase (state=0x7ffcdc3150f0, do_exec=0) at ../../Src/loop.c:658
#52 0x000055e7dc4526bd in execcmd (state=state@entry=0x7ffcdc3150f0, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=18, last1=2) at ../../Src/exec.c:3480
#53 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc3150f0, pcode=<optimized out>, how=how@entry=18, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#54 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc3150f0, slcode=<optimized out>, how=how@entry=18, last1=0) at ../../Src/exec.c:1527
#55 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc3150f0, dont_change_job=dont_change_job@entry=1, exiting=exiting@entry=0) at ../../Src/exec.c:1285
#56 0x000055e7dc479aa7 in execwhile (state=0x7ffcdc3150f0, do_exec=<optimized out>) at ../../Src/loop.c:452
#57 0x000055e7dc4526bd in execcmd (state=state@entry=0x7ffcdc3150f0, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=18, last1=2) at ../../Src/exec.c:3480
#58 0x000055e7dc45420e in execpline2 (state=state@entry=0x7ffcdc3150f0, pcode=<optimized out>, how=how@entry=18, input=0, output=0, last1=last1@entry=0) at ../../Src/exec.c:1749
#59 0x000055e7dc4545ec in execpline (state=state@entry=0x7ffcdc3150f0, slcode=<optimized out>, how=how@entry=18, last1=0) at ../../Src/exec.c:1527
#60 0x000055e7dc455ddc in execlist (state=state@entry=0x7ffcdc3150f0, dont_change_job=dont_change_job@entry=0, exiting=exiting@entry=0) at ../../Src/exec.c:1285
#61 0x000055e7dc4561f0 in execode (p=p@entry=0x7f0537709eb0, dont_change_job=dont_change_job@entry=0, exiting=exiting@entry=0, context=context@entry=0x55e7dc4c1189 "toplevel") at ../../Src/exec.c:1076
#62 0x000055e7dc469f13 in loop (toplevel=toplevel@entry=1, justonce=justonce@entry=0) at ../../Src/init.c:208
#63 0x000055e7dc46d55e in zsh_main (argc=<optimized out>, argv=<optimized out>) at ../../Src/init.c:1684
#64 0x00007f05369e8870 in __libc_start_main (main=0x55e7dc438230 <main>, argc=5, argv=0x7ffcdc315448, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffcdc315438) at libc-start.c:291
#65 0x000055e7dc438269 in _start ()

The full line with which zsh has been linked in the end was:

gcc -Wl,--as-needed -g -fPIE -pie -Wl,-z,relro -Wl,-z,now -rdynamic \
 -o zsh main.o `cat stamp-modobjs` -lgdbm -lpcre -lcap -ldl \
 -lncursesw -lrt -lm -lc

The full list of parameters passed to make seem to be in this line (originally
without the line breaks):

make -f Makemod prefix='/usr' exec_prefix='/usr' bindir='/bin'
libdir='/usr/lib/x86_64-linux-gnu'
MODDIR='/usr/lib/x86_64-linux-gnu/zsh/5.2-dev-1'
infodir='/usr/share/info' mandir='/usr/share/man' datadir='/usr/share'
fndir='/usr/share/zsh/functions' htmldir='/usr/share/zsh/htmldoc'
runhelpdir='/usr/share/zsh/5.2-dev-1/help' CC='gcc'
CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2 ' DEFS='-DHAVE_CONFIG_H'
CFLAGS='-g -O2 -fPIE -fstack-protector-strong -Wformat
-Werror=format-security -Wall -g' LDFLAGS='-Wl,--as-needed -g -fPIE
-pie -Wl,-z,relro -Wl,-z,now' EXTRA_LDFLAGS='-rdynamic'
DLCFLAGS='-fPIC' DLLDFLAGS='-shared' LIBLDFLAGS='' EXELDFLAGS=''
LIBS='-lgdbm -lpcre -lcap -ldl -lncursesw -lrt -lm  -lc' DL_EXT='so'
DLLD='gcc' AWK='gawk' ANSI2KNR=': ansi2knr' YODL='yodl -k -L'
YODL2TXT='yodl2txt' YODL2HTML='yodl2html' FUNCTIONS_INSTALL=''
tzsh='zsh' prep

HTH!

		Regards, Axel
-- 
 ,''`.  |  Axel Beckert <[email-masked]>, http://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5
  `-    |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE