Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Nov 2016 16:41:06 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Cc:        Nathan Whitehorn <nwhitehorn@freebsd.org>, Dimitry Andric <dim@FreeBSD.org>, Justin Hibbits <chmeeedalf@gmail.com>, Ed Maste <emaste@freebsd.org>
Subject:   Re: clang 3.9.0 vs. TARGET_ARCH=powerpc: fsck_ufs and "df -m" are example failures: __floatdidf gets SIGSEGV's in both of them.
Message-ID:  <871B0604-B8C8-41B3-A6E5-13DFCE048128@dsl-only.net>
In-Reply-To: <82B4883E-250C-4D93-A139-7949665C1B77@dsl-only.net>
References:  <82B4883E-250C-4D93-A139-7949665C1B77@dsl-only.net>

next in thread | previous in thread | raw e-mail | index | archive | help
[Summary: Looking around with gdb at fsck_ufs I found two __floatdidf =
routines
with different code. df has the same.]

On 2016-Nov-26, at 3:39 PM, Mark Millard <markmi at dsl-only.net> wrote:

> I updated to head -r309197 (with a work around for -r309144 breaking =
the build).
>=20
> This was on amd64, then used it to try to cross buildworld using clang =
3.9.0 for
> TARGET_ARCH=3Dpowerpc . The build completed. (I've been using clang =
3.8.0 this way
> for a long time.)
>=20
> [The kernel here was cross built via gcc 4.2.1, as has been my normal =
procedure.
> The kernel still has my "red zone for signal delivery" hack that was a =
workaround
> for clang 3.8.0 stack-handling ABI violations.]
>=20
> Booting, however, had problems because of fsck_ufs getting signal 11 =
and ended up
> initially in single user mode.
>=20
> Exiting single user did finish the boot. But "df -m" core dumps. (I've =
not
> explored much else.)
>=20
> Turns out that both fsck_ufs and "df -m" fail in the same routine for =
a SIGSEGV:
> __floatdidf
>=20
>=20
> The details. . .
>=20
> First the boot and fsck_ufs:
>=20
>> Copyright (c) 1992-2016 The FreeBSD Project.
>> Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, =
1994
>>        The Regents of the University of California. All rights =
reserved.
>> FreeBSD is a registered trademark of The FreeBSD Foundation.
>> FreeBSD 12.0-CURRENT #9 r309179M: Sat Nov 26 12:53:11 PST 2016
>>    =
markmi@FreeBSDx64:/usr/obj/powerpcvtsc_clang_gcc421_kernel/powerpc.powerpc=
/usr/src/sys/GENERICvtsc-NODBG powerpc
>> gcc version 4.2.1 20070831 patched [FreeBSD]
>> cpu0: IBM PowerPC 970MP revision 1.1, 18446744071914.91 MHz
>> cpu0: Features dc000000<PPC32,PPC64,ALTIVEC,FPU,MMU>
>> cpu0: HID0 1511081<DEEPNAP,NAP,DPM,NHR,TBEN,ENATTN>
>> real memory  =3D 2118565888 (2020 MB)
>> avail memory =3D 2014863360 (1921 MB)
>> FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
>> . . .
>> Trying to mount root  from ufs:/dev/ufs/FBSDG4Srootfs [rw,noatime]...
>> . . .
>> pid 53 (fsck_ufs), uid 0: exited on signal 11
>=20
>=20
> Manually running fsck later gets a segmentation fault core file in =
/var/crash/
> and I used this too see a point of failure (__floatdidf):
>=20
>> # fsck /
>> ** /dev/ufs/FBSDG4Srootfs (NO WRITE)
>> ** Last Mounted on /
>> ** Root file system
>> ** Phase 1 - Check Blocks and Sizes
>> INCORRECT BLOCK COUNT I=3D11538459 (8 should be 0)
>> CORRECT? no
>>=20
>> ** Phase 2 - Check Pathnames
>> ** Phase 3 - Check Connectivity
>> ** Phase 4 - Check Reference Counts
>> LINK COUNT FILE I=3D10016041  OWNER=3Doperator MODE=3D100400
>> SIZE=3D4096 MTIME=3DNov 26 14:44 2016  COUNT 2 SHOULD BE 1
>> ADJUST? no
>>=20
>> LINK COUNT FILE I=3D10016049  OWNER=3Doperator MODE=3D100400
>> SIZE=3D4096 MTIME=3DNov 26 14:55 2016  COUNT 2 SHOULD BE 1
>> ADJUST? no
>>=20
>> LINK COUNT FILE I=3D10016089  OWNER=3Doperator MODE=3D100400
>> SIZE=3D4096 MTIME=3DNov 26 15:00 2016  COUNT 2 SHOULD BE 1
>> ADJUST? no
>>=20
>> UNREF FILE  I=3D11538459  OWNER=3Droot MODE=3D100600
>> SIZE=3D0 MTIME=3DNov 26 15:11 2016=20
>> RECONNECT? no
>>=20
>>=20
>> CLEAR? no
>>=20
>> ** Phase 5 - Check Cyl groups
>> FREE BLK COUNT(S) WRONG IN SUPERBLK
>> SALVAGE? no
>>=20
>> SUMMARY INFORMATION BAD
>> SALVAGE? no
>>=20
>> BLK(S) MISSING IN BIT MAPS
>> SALVAGE? no
>>=20
>> fsck: /dev/ufs/FBSDG4Srootfs: Segmentation fault
>=20
>=20
>> # gdb fsck_ufs /var/crash/fsck_ufs.1129.core=20
>> GNU gdb 6.1.1 [FreeBSD]
>> Copyright 2004 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and =
you are
>> welcome to change it and/or distribute copies of it under certain =
conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB.  Type "show warranty" for =
details.
>> This GDB was configured as "powerpc-marcel-freebsd"...
>> Core was generated by `fsck_ufs /dev/ufs/FBSDG4Srootfs'.
>> Program terminated with signal 11, Segmentation fault.
>> Reading symbols from /lib/libufs.so.6...Reading symbols from =
/usr/lib/debug//lib/libufs.so.6.debug...done.
>> done.
>> Loaded symbols for /lib/libufs.so.6
>> Reading symbols from /lib/libc.so.7...Reading symbols from =
/usr/lib/debug//lib/libc.so.7.debug...done.
>> done.
>> Loaded symbols for /lib/libc.so.7
>> Reading symbols from /libexec/ld-elf.so.1...Reading symbols from =
/usr/lib/debug//libexec/ld-elf.so.1.debug...done.
>> done.
>> Loaded symbols for /libexec/ld-elf.so.1
>> #0  0x0181b024 in __floatdidf ()
>> (gdb) bt
>> #0  0x0181b024 in __floatdidf ()
>> #1  0x0180a8e0 in main (argc=3D<value optimized out>, argv=3D<value =
optimized out>) at /usr/src/sbin/fsck_ffs/main.c:519
>> #2  0x01801664 in _start ()
>> #3  0x418303a0 in .text () at =
/usr/src/libexec/rtld-elf/powerpc/rtld_start.S:112
>=20
> main.c's line 519 is part of:
>=20
>>        printf("(%ju frags, %ju blocks, %.1f%% fragmentation)\n",
>>            (uintmax_t)n_ffree, (uintmax_t)n_bfree,
>>            n_ffree * 100.0 / sblock.fs_dsize);
>=20
>=20
>=20
> As for "df -m" --it failed in __floatdidf as well:
>=20
>> # gdb df /var/crash/df.1056.core                                      =
                                                                         =
                                                         GNU gdb 6.1.1 =
[FreeBSD]
>> Copyright 2004 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and =
you are
>> welcome to change it and/or distribute copies of it under certain =
conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB.  Type "show warranty" for =
details.
>> This GDB was configured as "powerpc-marcel-freebsd"...
>> Core was generated by `df -m'.
>> Program terminated with signal 11, Segmentation fault.
>> Reading symbols from /lib/libxo.so.0...Reading symbols from =
/usr/lib/debug//lib/libxo.so.0.debug...done.
>> done.
>> Loaded symbols for /lib/libxo.so.0
>> Reading symbols from /lib/libutil.so.9...Reading symbols from =
/usr/lib/debug//lib/libutil.so.9.debug...done.
>> done.
>> Loaded symbols for /lib/libutil.so.9
>> Reading symbols from /lib/libc.so.7...Reading symbols from =
/usr/lib/debug//lib/libc.so.7.debug...done.
>> done.
>> Loaded symbols for /lib/libc.so.7
>> Reading symbols from /libexec/ld-elf.so.1...Reading symbols from =
/usr/lib/debug//libexec/ld-elf.so.1.debug...done.
>> done.
>> Loaded symbols for /libexec/ld-elf.so.1
>> #0  0x01802a18 in __floatdidf ()
>> (gdb) bt
>> #0  0x01802a18 in __floatdidf ()
>> #1  0x01802538 in prtstat (sfsp=3D0x41e24000, mwp=3D0xffffd930) at =
/usr/src/bin/df/df.c:503
>> #2  0x01801df0 in main (argc=3D<value optimized out>, argv=3D<value =
optimized out>) at /usr/src/bin/df/df.c:308
>> #3  0x01800cdc in _start ()
>> #4  0x418153a0 in .text () at =
/usr/src/libexec/rtld-elf/powerpc/rtld_start.S:112
>=20
> df.c's line 503 was part of:
>=20
>>        xo_emit(" {:used-percent/%5.0f}{U:%%}",
>>            availblks =3D=3D 0 ? 100.0 : (double)used / =
(double)availblks * 100.0);
>=20
>=20
>=20
> Context details:
>=20
>> # head =
~/sys_typescripts/typescript_make_powerpcvtsc_nodebug_clang_bootstrap_worl=
d-amd64-host-2016-11-26:11:38:36=20
>> Script started on Sat Nov 26 11:38:36 2016
>> Command: env __MAKE_CONF=3D/root/src.configs/make.conf =
SRCCONF=3D/dev/null =
SRC_ENV_CONF=3D/root/src.configs/src.conf.powerpc-clang-bootstrap.amd64-ho=
st WITH_META_MODE=3Dyes =
MAKEOBJDIRPREFIX=3D/usr/obj/powerpcvtsc_clang_world make -j 5 buildworld
>> --- buildworld ---
>=20
> . . .
>=20
>=20
>> # more ~/src.configs/src.conf.powerpc-clang-bootstrap.amd64-host
>> TO_TYPE=3Dpowerpc
>> #
>> KERNCONF=3DGENERICvtsc-NODBG
>> TARGET=3D${TO_TYPE}
>> .if ${.MAKE.LEVEL} =3D=3D 0
>> TARGET_ARCH=3D${TO_TYPE}
>> .export TARGET_ARCH
>> .endif
>> #
>> WITH_CROSS_COMPILER=3D
>> WITHOUT_SYSTEM_COMPILER=3D
>> #
>> WITH_LIBCPLUSPLUS=3D
>> WITH_BINUTILS_BOOTSTRAP=3D
>> WITH_CLANG_BOOTSTRAP=3D
>> WITH_CLANG=3D
>> WITH_CLANG_IS_CC=3D
>> WITH_CLANG_FULL=3D
>> WITH_CLANG_EXTRAS=3D
>> # lldb requires missing atomic 8-byte operations for powerpc (non-64)
>> WITHOUT_LLDB=3D
>> #
>> WITH_BOOT=3D
>> WITHOUT_LIB32=3D
>> #
>> WITHOUT_ELFTOOLCHAIN_BOOTSTRAP=3D
>> WITHOUT_GCC_BOOTSTRAP=3D
>> WITHOUT_GCC=3D
>> WITHOUT_GCC_IS_CC=3D
>> WITHOUT_GNUCXX=3D
>> #
>> NO_WERROR=3D
>> #WERROR=3D
>> MALLOC_PRODUCTION=3D
>> #
>> WITH_DEBUG_FILES=3D
>=20
>=20
>> # more ~/src.configs/make.conf=20
>> CFLAGS.gcc+=3D -v

Looking around in gdb there seem to be two __floatdidf routines with =
differing code.

First showing the one that was used and failed:

(gdb) x/50i 0x0181afc0
. . .
0x181afcc <__floatdidf>:	mflr    r0
0x181afd0 <__floatdidf+4>:	stw     r0,4(r1)
0x181afd4 <__floatdidf+8>:	stwu    r1,-32(r1)
0x181afd8 <__floatdidf+12>:	stw     r31,28(r1)
0x181afdc <__floatdidf+16>:	stw     r30,24(r1)
0x181afe0 <__floatdidf+20>:	bl      0x182e96c <.got+20>
0x181afe4 <__floatdidf+24>:	mr      r31,r1
0x181afe8 <__floatdidf+28>:	xoris   r3,r3,32768
0x181afec <__floatdidf+32>:	lis     r5,17200
0x181aff0 <__floatdidf+36>:	mflr    r30
0x181aff4 <__floatdidf+40>:	stw     r3,12(r31)
0x181aff8 <__floatdidf+44>:	stw     r5,8(r31)
0x181affc <__floatdidf+48>:	lwz     r3,-16(r30)
0x181b000 <__floatdidf+52>:	lwz     r6,-20(r30)
0x181b004 <__floatdidf+56>:	lfd     f1,8(r31)
0x181b008 <__floatdidf+60>:	stw     r4,20(r31)
0x181b00c <__floatdidf+64>:	stw     r5,16(r31)
0x181b010 <__floatdidf+68>:	lfd     f13,16(r31)
0x181b014 <__floatdidf+72>:	lwz     r0,36(r1)
0x181b018 <__floatdidf+76>:	lwz     r31,28(r1)
0x181b01c <__floatdidf+80>:	lwz     r30,24(r1)
0x181b020 <__floatdidf+84>:	lfs     f2,0(r3)
0x181b024 <__floatdidf+88>:	lwz     r3,-12(r30)
0x181b028 <__floatdidf+92>:	lfs     f0,0(r6)
0x181b02c <__floatdidf+96>:	lfs     f12,0(r3)
0x181b030 <__floatdidf+100>:	fsub    f0,f1,f0
0x181b034 <__floatdidf+104>:	fmul    f0,f0,f2
0x181b038 <__floatdidf+108>:	fadd    f0,f0,f12
0x181b03c <__floatdidf+112>:	fadd    f1,f13,f0
0x181b040 <__floatdidf+116>:	addi    r1,r1,32
0x181b044 <__floatdidf+120>:	mtlr    r0
0x181b048 <__floatdidf+124>:	blr
. . .

Then showing the one that was not used that I found:

(gdb) disass __floatdidf
Dump of assembler code for function __floatdidf:
0x4199fc8c <__floatdidf+0>:	mflr    r0
0x4199fc90 <__floatdidf+4>:	stw     r0,4(r1)
0x4199fc94 <__floatdidf+8>:	stwu    r1,-32(r1)
0x4199fc98 <__floatdidf+12>:	stw     r31,28(r1)
0x4199fc9c <__floatdidf+16>:	stw     r30,24(r1)
0x4199fca0 <__floatdidf+20>:	mr      r31,r1
0x4199fca4 <__floatdidf+24>:	srawi   r5,r3,31
0x4199fca8 <__floatdidf+28>:	bl      0x41a0a288 <.got+14428>
0x4199fcac <__floatdidf+32>:	cmpwi   r3,0
0x4199fcb0 <__floatdidf+36>:	addc    r6,r4,r5
0x4199fcb4 <__floatdidf+40>:	adde    r6,r3,r5
0x4199fcb8 <__floatdidf+44>:	lis     r3,17200
0x4199fcbc <__floatdidf+48>:	xor     r5,r6,r5
0x4199fcc0 <__floatdidf+52>:	mflr    r30
0x4199fcc4 <__floatdidf+56>:	bge-    0x4199fccc <__floatdidf+64>
0x4199fcc8 <__floatdidf+60>:	neg     r4,r4
0x4199fccc <__floatdidf+64>:	lwz     r12,-3124(r30)
0x4199fcd0 <__floatdidf+68>:	stw     r5,20(r31)
0x4199fcd4 <__floatdidf+72>:	stw     r4,12(r31)
0x4199fcd8 <__floatdidf+76>:	lwz     r4,-3120(r30)
0x4199fcdc <__floatdidf+80>:	stw     r3,16(r31)
0x4199fce0 <__floatdidf+84>:	stw     r3,8(r31)
0x4199fce4 <__floatdidf+88>:	lfd     f1,16(r31)
0x4199fce8 <__floatdidf+92>:	lfd     f3,8(r31)
0x4199fcec <__floatdidf+96>:	lfs     f0,0(r12)
0x4199fcf0 <__floatdidf+100>:	lfs     f2,0(r4)
0x4199fcf4 <__floatdidf+104>:	fsub    f1,f1,f0
0x4199fcf8 <__floatdidf+108>:	fsub    f0,f3,f0
0x4199fcfc <__floatdidf+112>:	fmul    f1,f1,f2
0x4199fd00 <__floatdidf+116>:	fadd    f1,f0,f1
0x4199fd04 <__floatdidf+120>:	bge-    0x4199fd0c <__floatdidf+128>
0x4199fd08 <__floatdidf+124>:	fneg    f1,f1
0x4199fd0c <__floatdidf+128>:	lwz     r0,36(r1)
0x4199fd10 <__floatdidf+132>:	lwz     r31,28(r1)
0x4199fd14 <__floatdidf+136>:	lwz     r30,24(r1)
0x4199fd18 <__floatdidf+140>:	addi    r1,r1,32
0x4199fd1c <__floatdidf+144>:	mtlr    r0
0x4199fd20 <__floatdidf+148>:	blr
End of assembler dump.

=3D=3D=3D
Mark Millard
markmi at dsl-only.net




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?871B0604-B8C8-41B3-A6E5-13DFCE048128>