OpenAFS Master Repository branch, master, updated. BP-openafs-stable-1_8_x-435-g0a39efe
Gerrit Code Review
Sun, 25 Aug 2019 20:01:53 -0400
The following commit has been merged in the master branch:
Author: Andrew Deason <email@example.com>
Date: Sun Jul 14 17:31:30 2019 -0500
FBSD: Use ucontext for FreeBSD 10+ on amd64
Currently, running any LWP program on recent FreeBSD on amd64 causes
(or can cause) a SIGBUS very quickly. This is possibly because our
stack management code in LWP only ensures our stacks are 4 or 8-byte
aligned in most cases (except DARWIN, which gets 16-byte-aligned
stacks), according to the value of STACK_ALIGN. The amd64 ABI mandates
that stacks be 16-byte-aligned, and some function calls assume that
this is followed, causing a SIGBUS when it is not. FreeBSD on amd64
currently uses process.amd64.s for its savecontext() implementation,
which does not do any checking or fixup of the stack alignment.
This behavior has been observed on amd64 with FreeBSD 11 specifically,
but it probably happens on any FreeBSD release when using clang.
FreeBSD switched to clang as the default compiler with FreeBSD 10, so
this probably occurs with FreeBSD 10 and newer.
We could perhaps try to fix this by changing our stack management
code, but we can also avoid most of this nonsense by just using
ucontext instead of our custom assembly code. So, do that, by setting
USE_UCONTEXT for FreeBSD 10+. Also enable the same 'stackvar'-based
workaround in savecontext() as Linux uses, since otherwise 'topstack'
appears to always be NULL, and triggers our stack overflow checks.
Note that while LWP use is deprecated, as of this commit many small
utilities (like 'fs') are still linked to LWP, and so are unusable
without a fix like this.
Reviewed-by: Benjamin Kaduk <firstname.lastname@example.org>
Tested-by: Benjamin Kaduk <email@example.com>
src/config/param.amd64_fbsd_100.h | 2 ++
src/config/param.amd64_fbsd_101.h | 2 ++
src/config/param.amd64_fbsd_102.h | 2 ++
src/config/param.amd64_fbsd_103.h | 2 ++
src/config/param.amd64_fbsd_104.h | 2 ++
src/config/param.amd64_fbsd_110.h | 2 ++
src/config/param.amd64_fbsd_111.h | 2 ++
src/config/param.amd64_fbsd_112.h | 2 ++
src/config/param.amd64_fbsd_120.h | 2 ++
src/lwp/Makefile.in | 2 ++
src/lwp/process.c | 14 +++++++++-----
11 files changed, 29 insertions(+), 5 deletions(-)
OpenAFS Master Repository