Kyle Evans 4be0a1b587 _umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE
Specifically, if we're waking up some value n > BATCH_SIZE, then the
copyin(9) is wrong on the second iteration due to upp being the wrong type.
upp is currently a uint32_t**, so upp + pos advances it by twice as many
elements as it should (host pointer size vs. compat32 pointer size).

Fix it by just making upp a uint32_t*; it's still technically a double
pointer, but the distinction doesn't matter all that much here since we're
just doing arithmetic on it.

Add a test case that demonstrates the problem, placed with the libthr tests
since one messing with _umtx_op should be running these tests. Running under
compat32, the new test case will hang as threads after the first 128 get
missed in the wake. it's not immediately clear how to hit it in practice,
since pthread_cond_broadcast() uses a smaller (sleepq batch?) size observed
to be around ~50 -- I did not spend much time digging into it.

The uintptr_t change makes no functional difference, but i've tossed it in
since it's more accurate (semantically).

Reported by:	Andrew Gierth (andrew_tao173.riddles.org.uk, inspection)
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27231
2020-11-17 03:34:01 +00:00

60 lines
1.4 KiB
Makefile

# $FreeBSD$
PACKAGE= tests
WARNS?= 3
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread
# TODO: t_name (missing pthread_getname_np support in FreeBSD)
NETBSD_ATF_TESTS_C= barrier_test
NETBSD_ATF_TESTS_C+= cond_test
NETBSD_ATF_TESTS_C+= condwait_test
NETBSD_ATF_TESTS_C+= detach_test
NETBSD_ATF_TESTS_C+= equal_test
NETBSD_ATF_TESTS_C+= fork_test
NETBSD_ATF_TESTS_C+= fpu_test
NETBSD_ATF_TESTS_C+= join_test
NETBSD_ATF_TESTS_C+= kill_test
NETBSD_ATF_TESTS_C+= mutex_test
NETBSD_ATF_TESTS_C+= once_test
NETBSD_ATF_TESTS_C+= preempt_test
NETBSD_ATF_TESTS_C+= rwlock_test
NETBSD_ATF_TESTS_C+= sem_test
NETBSD_ATF_TESTS_C+= sigmask_test
NETBSD_ATF_TESTS_C+= sigsuspend_test
NETBSD_ATF_TESTS_C+= siglongjmp_test
NETBSD_ATF_TESTS_C+= sleep_test
.if ${MACHINE_CPUARCH} != "aarch64" # ARM64TODO: Missing makecontext
NETBSD_ATF_TESTS_C+= swapcontext_test
.endif
NETBSD_ATF_TESTS_C+= timedmutex_test
NETBSD_ATF_TESTS_SH= atexit_test
NETBSD_ATF_TESTS_SH+= cancel_test
NETBSD_ATF_TESTS_SH+= exit_test
NETBSD_ATF_TESTS_SH+= resolv_test
ATF_TESTS_C+= umtx_op_test
LIBADD+= pthread
LIBADD.fpu_test+= m
LIBADD.sem_test+= rt
BINDIR= ${TESTSDIR}
PROGS= h_atexit
PROGS+= h_cancel
PROGS+= h_exit
PROGS+= h_resolv
${PACKAGE}FILES+= d_mach
TESTS_SUBDIRS= dlopen
.include <netbsd-tests.test.mk>
CFLAGS.condwait_test+= -I${SRCTOP}/contrib/netbsd-tests/lib/libc/gen
.include <bsd.test.mk>