Module Name: src Committed By: martin Date: Wed Oct 23 19:25:39 UTC 2019
Modified Files: src/sys/kern [netbsd-9]: kern_sig.c sys_ptrace_common.c src/tests/lib/libc/sys [netbsd-9]: t_ptrace_wait.c Log Message: Pull up following revision(s) (requested by kamil in ticket #366): tests/lib/libc/sys/t_ptrace_wait.c: revision 1.136 sys/kern/kern_sig.c: revision 1.373 tests/lib/libc/sys/t_ptrace_wait.c: revision 1.138 tests/lib/libc/sys/t_ptrace_wait.c: revision 1.139 sys/kern/kern_sig.c: revision 1.376 tests/lib/libc/sys/t_ptrace_wait.c: revision 1.140 sys/kern/sys_ptrace_common.c: revision 1.64 Fix typo in a comment Enable TEST_LWP_ENABLED in t_ptrace_wait* The LWP events (created, exited) are now reliable in my local tests. PR kern/51420 PR kern/51995 Remove the short-circuit lwp_exit() path from sigswitch() sigswitch() can be called from exit1() through: ttywait()->ttysleep()-> cv_timedwait_sig()->sleepq_block()->issignal()->sigswitch() lwp_exit() called for the last LWP triggers exit1() and this causes a panic. The debugger related signals have short-circuit demise paths in eventswitch() and other functions, before calling sigswitch(). This change restores the original behavior, but there is an open question whether the kernel crash is a red herring of misbehavior of ttywait(). This should fix PR kern/54618 by David H. Gutteridge Fix a race condition when handling concurrent LWP signals and add a test Fix a race condition that caused PT_GET_SIGINFO to return incorrect information when multiple signals were delivered concurrently to different LWPs. Add a regression test that verifies that when 50 threads concurrently use pthread_kill() on themselves, the debugger receives all signals with correct information. The kernel uses separate signal queues for each LWP. However, the signal context used to implement PT_GET_SIGINFO is stored in 'struct proc' and therefore common to all LWPs in the process. Previously, this member was filled in kpsignal2(), i.e. when the signal was sent. This meant that if another LWP managed to send another signal concurrently, the data was overwritten before the process was stopped. As a result, PT_GET_SIGINFO did not report the correct LWP and signal (it could even report a different signal than wait()). This can be quite reliably reproduced with the number of 20 LWPs, however it can also occur with 10. This patch moves setting of signal context to issignal(), just before the process is actually stopped. The data is taken from per-LWP or per-process signal queue. The added test confirms that the debugger correctly receives all signals, and PT_GET_SIGINFO reports both correct LWP and signal number. Reviewed by kamil. Remove preprocessor switch TEST_VFORK_ENABLED in t_ptrace_wait* vfork(2) tests are now enabled always and confirmed to be stable. Remove preprocessor switch TEST_LWP_ENABLED in t_ptrace_wait* LWP tests are now enabled always and confirmed to be stable. To generate a diff of this commit: cvs rdiff -u -r1.364.2.7 -r1.364.2.8 src/sys/kern/kern_sig.c cvs rdiff -u -r18.104.22.168 -r22.214.171.124 src/sys/kern/sys_ptrace_common.c cvs rdiff -u -r126.96.36.199 -r188.8.131.52 src/tests/lib/libc/sys/t_ptrace_wait.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.