Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Oct 2016 16:02:26 -0700
From:      Mark Millard <markmi@dsl-only.net>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-current@freebsd.org, freebsd-arm <freebsd-arm@freebsd.org>, FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>
Subject:   Re: stable/11 -r307797 on BPi-M3 (cortex-a7): truss gets segmentation fault for handling unknown system call
Message-ID:  <C3B549C5-AF5B-458C-961D-9C45C63218F5@dsl-only.net>
In-Reply-To: <2661167.K5IN9JAPmQ@ralph.baldwin.cx>
References:  <0699F744-DEB3-4ED5-91A9-B77EA2ACED37@dsl-only.net> <2661167.K5IN9JAPmQ@ralph.baldwin.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2016-Oct-28, at 7:29 AM, John Baldwin <jhb at freebsd.org> wrote:

> On Tuesday, October 25, 2016 11:40:38 AM Mark Millard wrote:
>> [The following has been reported in: =
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D213778 .]
>>=20
>> In trying to build lang/gcc6 xgcc's cc1 got some SIGSYS examples. In =
trying to track things down I ran into truss getting a SIGSEGV when it =
tries to handle the situation. . .
>>=20
>> In truss's enter_syscall there is (from a live gdb on truss, after =
the segmentation fault):
>>=20
>> 380		t->cs.name =3D sysdecode_syscallname(t->proc->abi->abi, =
t->cs.number);
>> 381		if (t->cs.name =3D=3D NULL)
>> (gdb)=20
>> 382			fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d =
--\n",
>> 383			    t->proc->abi->type, t->cs.number);
>> 384=09
>> 385		sc =3D get_syscall(t->cs.name, narg);
>> 386		t->cs.nargs =3D sc->nargs;
>> 387		assert(sc->nargs <=3D nitems(t->cs.s_args));
>> 388=09
>> 389		t->cs.sc =3D sc;
>>=20
>> (gdb) print *t
>> $2 =3D {entries =3D {le_next =3D 0x0, le_prev =3D 0x20617070}, proc =3D=
 0x20617060, tid =3D 100150, in_syscall =3D 1, cs =3D {sc =3D 0x0, name =
=3D 0x0, number =3D 580828064, args =3D 0x2061b0c0, nargs =3D 0,=20
>>    s_args =3D 0x2061b0ec}, before =3D {tv_sec =3D 1477418265, tv_nsec =
=3D 492342263}, after =3D {tv_sec =3D 1477418265, tv_nsec =3D =
492496630}}
>>=20
>> (gdb) print sc
>> $3 =3D (struct syscall *) 0x0
>>=20
>> So line 386 listed above gets a segmentation fault for sc->nargs when =
t->cs.name is a NULL pointer: sc ends up NULL.
>>=20
>> Looking at the two things that the fprintf on lines 382 and 383 would =
report:
>>=20
>> (gdb) print t->proc->abi->type
>> $4 =3D 0x10166 "FreeBSD ELF32"
>>=20
>> (gdb) print t->cs.number
>> $5 =3D 580828064
>>=20
>> (gdb) print narg
>> $6 =3D 0
>>=20
>> (that last is for context for the get_syscall arguments).
>>=20
>> FYI: 580828064 =3D 0x229EBBA0
>=20
> I have a patchset I have tested some in a git branch that I believe =
fixes handling of
> unknown system calls.  Please try this:
>=20
> =
https://github.com/freebsd/freebsd/compare/master...bsdjhb:truss_unknown
>=20
> (Add .diff to get a diff you can apply with patch)
>=20
> --=20
> John Baldwin

Sorry it took so long to try the build. . .

I got a compile failure for use of bool in my stable/11 context for the =
BPI-M3 build that the truss problem was discovered with (quoting the =
build log below):

> --- main.o ---
> cc -target armv6-gnueabihf-freebsd11.0 =
--sysroot=3D/usr/local/src/crochet/work/obj/arm.armv6/usr/src/tmp =
-B/usr/local/src/crochet/work/obj/arm.armv6/usr/src/tmp/usr/bin -O -pipe =
-I/usr/src/usr.bin/truss -I. -I/usr/src/usr.bin/truss/../../sys   -g -MD =
 -MF.depend.main.o -MTma
> in.o -std=3Dgnu99 -Wsystem-headers -Wall -Wno-format-y2k -W =
-Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes =
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch =
-Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline =
-Wnested-externs=20
> -Wredundant-decls -Wold-style-definition -Wno-pointer-sign =
-Wmissing-variable-declarations -Wthread-safety -Wno-empty-body =
-Wno-string-plus-int -Wno-unused-const-variable  -Qunused-arguments  -c =
/usr/src/usr.bin/truss/main.c -o main.o
> In file included from /usr/src/usr.bin/truss/main.c:53:
> /usr/src/usr.bin/truss/syscall.h:75:2: error: unknown type name 'bool'
>         bool unknown;   /* Uknown system call */
>         ^
> 1 error generated.
> *** [main.o] Error code 1
>=20
> make[4]: stopped in /usr/src/usr.bin/truss
> 1 error


In C99 bool is a macro from <stdbool.h> and _Bool is the  C99 type =
itself. So apparently <stdbool.h> (or an equivalent) was not directly or =
indirectly included. (The macros true and false and =
__bool_true_false_are_defined are also from <stdbool.h> .)

Which way do you want the C99 typing to be handled for this: native C99 =
with no <stdbool.h> required? Use <stdbool.h> ?


Side note:

I'll see about getting my normal stable/11 build environment going for =
the BPI-M3 instead of using the crochet from my first-time build for the =
target.

=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?C3B549C5-AF5B-458C-961D-9C45C63218F5>