Home | History | Annotate | Download | only in sys
History log of /src/tests/lib/libc/sys/t_ptrace_wait.h
RevisionDateAuthorComments
 1.42  09-May-2025  riastradh t_ptrace_*: Put spaces in hexdump output for legibility.

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.41  09-May-2025  riastradh t_ptrace*: Fix FORKEE_ASSERT_MEMEQ output and failureness.

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.40  02-May-2025  riastradh t_ptrace_*: More diagnostic output for assertion failures.

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.39  02-May-2025  riastradh t_ptrace*: Show values in hex for FORKEE_ASSERT_EQ/NEQ.

Should make the output easier to read for:

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.38  02-May-2025  riastradh tests/lib/libc/sys/t_ptrace*: Sprinkle improved diagnostics.

This should make it easier to look at the test failure output and
figure out what's going on.

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.37  02-May-2025  riastradh tests/lib/libc/sys/t_ptrace*: Nix trailing whitespace.

No functional change intended.

Preparation for:

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.36  14-May-2024  riastradh branches: 1.36.2;
t_ptrace_wait: No FPU exception traps on RISC-V.

This macro is not named correctly -- RISC-V does implement
floating-point exceptions, but only via sticky status bits, not via
machine traps.
 1.35  14-May-2024  riastradh t_ptrace_wait: Force result by write to volatile, not call to usleep.

This is causing each FPE-related test to time out because it's
actually passinga large number to usleep, which now respects large
numbers.
 1.34  24-May-2022  andvar s/estabilishing/establishing/ in copy pasted comment.
 1.33  24-May-2021  gson On mips, avoid deliberately executing an illegal instruction for now
because it causes GXemul to exit rather than generating a trap. A bug
report has been sent to the GXemul author.
 1.32  22-Jun-2020  rin branches: 1.32.4;
Work around QEMU bug #1668041 differently, by which floating-point
division by zero is not correctly trapped for i386 and amd64:

https://bugs.launchpad.net/qemu/+bug/1668041

Make trigger_fpe() cause integer division by zero for x86, and
floating-point one for other architectures. Also, assertions for
si_code in *_crash_fpe tests are commented out for now. They
should be cleaned up after the bug is fixed.

Now, *_crash_fpe tests are working also on powerpc.

Suggested by kamil.
 1.31  22-Jun-2020  rin Turn trigger_fpe() back to integer division by zero for a while
until QEMU bug #1668041 is fixed:

https://bugs.launchpad.net/qemu/+bug/1668041

by which floating-point division by zero is not trapped correctly
both on amd64 and i386.

Skip *_crash_fpe tests on powerpc, where integer division by zero
is never trapped.
 1.30  17-Jun-2020  rin Let trigger_fpe() cause floating-point divide by zero exception, instead of
integer one, which is not trapped for powerpc and aarch64.

Note that it is checked in lib/libc/gen/t_siginfo whether integer divide by
zero is interpreted as SIGFPE or not.

Now, all *_crash_fpe tests pass for powerpc, and nothing changes for amd64
at least.
 1.29  17-Jun-2020  rin Regardless of __HAVE_FENV, include <fenv.h>, which itself defines __HAVE_FENV.
 1.28  05-May-2020  kamil Move threads tests out of t_ptrace_wait.c to t_ptrace_threads_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
 1.27  08-Mar-2020  martin Only inlcude fenv.h if __HAVE_FENV
 1.26  07-Mar-2020  kamil Fix typo
 1.25  07-Mar-2020  christos Try to fix the build. This is why all those inlines should really be in a
separate file as regular function. The code is too large and hard to manage
this way, and only increases in complexity as time goes by.
 1.24  06-Mar-2020  kamil Add await_collected()

This functions waits for collecting a process.
 1.23  03-Mar-2020  kamil Mark find_event_count() with __used
 1.22  22-Feb-2020  kamil Disable t_ptrace_wait* tests for MKSANITIZER/MKLIBCSANITIZER

A subset of tests is not compatible with the sanitizers.
 1.21  13-Feb-2020  kamil Disable UBSan warnings for trigger_segv()

Dereferencing the NULL pointer is on purpose.
 1.20  13-Feb-2020  kamil Disable UBSan reports in trigger_fpe()

Division by 0 is on purpose.
 1.19  11-Feb-2020  kamil Rewrite the t_ptrace_wait resume1 test

Switch to pthread functions.
Rename to 'resume'.
Synchronize the threads with pthread barriers.
Avoid race in the test.

Test passes correctly.

Fixes PR bin/54893 by Andreas Gustafsson
 1.18  12-Nov-2019  kamil Rework thread_concurrent_signals and trace_thread_lwpcreate_and_exit

Change the code to remove the LWP id assumptions that broke after
src/sys/kern/kern_lwp.c r. 1.206.

Original code by <mgorny>, tested and tweaked by myself.
 1.17  25-May-2019  kamil Add get_user_va0_disable() in t_ptrace_wait.h

Add a utility function to check vm.user_va0_disable.
 1.16  25-Apr-2019  kamil Introduce check for the support of FPU exceptions

If FPU exceptions are unsupported, skip the SIGFPE crash tests.

Reuse code from tests/kernel/h_segv.c
 1.15  11-Apr-2019  kamil Add clone_func() in t_ptrace_wait.h
 1.14  10-Feb-2019  kamil Link t_ptrace_wait* tests with -pthread

While there, bump (c) for ATF ptrace(2) tests.

Add __used in infinite_thread() for consistency with other functions in
the file.
 1.13  09-Feb-2019  kamil Add infinite_thread() for ptrace(2) ATF tests

infinite_thread() is designed to be spawned as a pthread(3) function.

It will be used soon in new tests.
 1.12  13-Aug-2018  kamil Add await_stopped() in t_ptrace_wait.h

This is used in tests where a process awaits for a stopped process.
 1.11  30-May-2018  kamil branches: 1.11.2;
Add a comment for the workaround in trigger_bus()

Explain PROT_READ|PROT_WRITE.
 1.10  30-May-2018  kamil Make the trigger_bus() test compatible with more CPUs (at least ALPHA)

If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
- write register wide memory without rmw sequence,
- mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by <martin>
 1.9  27-May-2018  kamil Try to fool $CC harder in ATF ptrace(2) tests in trigger_fpe()

A function that returns a value that is not used, can be optimized out by
a compiler. Try to fool the compiler with calling libc functions that shall
trigger a division by zero crash.

Sponsored by <The NetBSD Foundation>
 1.8  26-May-2018  kamil Introduce can_we_write_to_text() to ATF ptrace(2) tests

The purpose of this function is to detect whether a tracer can write to the
.text section of its tracee.

Sponsored by <The NetBSD Foundation>
 1.7  24-May-2018  kamil Try to fix 32-bit build

Cast pointer to uintptr_t rather than uintmax_t.
 1.6  23-May-2018  kamil Add new auxiliary functions in ATF ptrace(2) tests

Introduce:
- trigger_trap()
- trigger_segv()
- trigger_ill()
- trigger_fpe()
- trigger_bus()

These functions generate appropriate signals caused by crashes.

A debugger is required to collect the crashes regardless of signal masking,
catching or ignoring rules.

While there, append __used argument to can_we_set_dbregs().

Sponsored by <The NetBSD Foundation>
 1.5  19-May-2018  kamil Add new auxiliary functions in t_ptrace_wait.h

New functions:
- FORKEE_ASSERT_NEQ()
- await_stopped_child()

Both will be used soon in a new ATF ptrace(2) test.

Sponsored by <The NetBSD Foundation>
 1.4  13-May-2018  kamil Refactor code in ATF ptrace(2) tests

Move the can_we_set_dbregs() auxiliary function from t_ptrace_x86_wait.h
to a common file t_ptrace_wait.h. This allows using this function for
checking whether the DBREGS set operations in ptrace(2) are accessible for
a user.

Sponsored by <The NetBSD Foundation>
 1.3  28-Apr-2018  kamil Handle core dumps in ATF ptrace(2) tests easier

Cast WCOREDUMP() to either 1 or 0.

It could be changed to a boolean type, but it's already good enough.

Sponsored by <The NetBSD Foundation>
 1.2  13-Mar-2018  kamil Add a new function in ATF t_ptrace_wait*: await_zombie_raw()

Add await_zombie_raw() that is the same as await_zombie(), whith an
addition of additional "useconds_t ms" parameter indicating delays between
new polling for a zombie process.

This new function will be used for testing a race condition that has been
observed occassionally crashing a test case -- returning duplicate entries
for KERN_PROC_PID.

Sponsored by <The NetBSD Foundation>
 1.1  02-Apr-2017  kamil branches: 1.1.2; 1.1.4; 1.1.8; 1.1.14;
Import ptrace(2) tests into appropriate directory tests/lib/libc/sys/

This is the correct directory documented in tests/README for such tests.

Discussed with <martin>

Sponsored by <The NetBSD Foundation>
 1.1.14.5  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.14.4  25-Jun-2018  pgoyette Sync with HEAD
 1.1.14.3  21-May-2018  pgoyette Sync with HEAD
 1.1.14.2  02-May-2018  pgoyette Synch with HEAD
 1.1.14.1  15-Mar-2018  pgoyette Synch with HEAD
 1.1.8.1  12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #711):
tests/lib/libc/sys/t_ptrace_wait.c: revision 1.24-1.31
tests/lib/libc/sys/t_ptrace_wait.h: revision 1.2
tests/lib/libc/sys/t_ptrace_x86_wait.h: revision 1.4,1.5
tests/lib/libc/sys/msg.h: revision 1.2

Correct all ATF failures in t_ptrace_x86_wait.h (debug registers)

This code after refactoring stopped calling functions that were designed
to trigger expected behavior and thus, tests were breaking.
Sponsored by <The NetBSD Foundation>

ATF: Correct a race bug in attach2 (t_ptrace_wait*)
At the end of the test we resume a tracer and expect to observe it to
collect the debuggee. We cannot from a parent point of view wait for
collecting it with WNOHANG without a race.

Remove the WNOHANG option from wait*(2) call. This corrects one type of
race.

This test is still racy for some other and unknown reason and this is bei=
ng
investigated.

Sponsored by <The NetBSD Foundation>

ATF: Reenable attach2 in t_ptrace_wait*

The primary race specific to this test has been fixed in previous commit
(wrong WNOHANG).

This test is still racy and breaks like once every 30,000 execution.
This is down like from once from every 100th execution in the past.
The remaning race is not specific to attach2 and I can reproduce it with
at least attach1. It still looks like being specific to NetBSD and it's
not reproducible on Linux and FreeBSD. Perhaps a bug with pipe(2)/write(2=
)/
read(2) or close to these features.

Sponsored by <The NetBSD Foundation>

Add a new function in ATF t_ptrace_wait*: await_zombie_raw()

Add await_zombie_raw() that is the same as await_zombie(), whith an
addition of additional "useconds_t ms" parameter indicating delays betwee=
n
new polling for a zombie process.

This new function will be used for testing a race condition that has been=
observed occassionally crashing a test case -- returning duplicate entrie=
s
for KERN_PROC_PID.

Sponsored by <The NetBSD Foundation>

ATF t_ptrace_wait*: Disable debug messages in msg.h
msg.h is a dummy IPC interface.

Disable additional debugging logging here, especially wanted in race*
tests.

Sponsored by <The NetBSD Foundation>

ATF: Add new test race1 in t_ptrace_wait*

Reuse the attach1's test body for race1.

Add a new test race1:
Assert that await_zombie() in attach1 always finds a single
process and no other error is reported
race1 requires HAVE_PID in wait(2)-like function.

This test is executed in a loop for 5 seconds (16k iterations on Intel i7=
).
A buggy kernel was asserting an error within this timeframe almost always=
=2E
The bug in the kernel is now gone and this test is expected to pass
correctly.

Sponsored by <The NetBSD Foundation>

Add check in ATF tests for security.models.extensions.user_set_dbregs
Introduce a new function can_we_set_dbregs() in the ATF ptrace(2) tests.

It uses lazy-bool evaluation whether a process can call PT_SETDBREGS.
In case of not being able to do so, print a message and mark a test
as skipped:
Either run this test as root or set sysctl(3)
security.models.extensions.user_set_dbregs to 1
No functional change intended to the code flow of the existing tested
scenarios.

Sponsored by <The NetBSD Foundation>

Improve documentation of the ATF test t_ptrace_wait*: traceme2
Set the description to:
Verify that a signal emitted by a tracer to a child is caught by
a signal handler.

Sponsored by <The NetBSD Foundation>

Merge code in tests: fork1 and vfork1 (ATF t_ptrace_wait*)

Marge bodies of two tests into the same function.

Add few checks for regular fork or not (vfork).

Sponsored by <The NetBSD Foundation>

ATF: ptrace: Merge code in fork2 and vfork2 tests with (v)fork1 ones
Reduce code duplication, use the same function body with conditional
switches.

Sponsored by <The NetBSD Foundation>

ATF t_ptrace_wait* refactoring: vforkdone1 and vforkdone2

Merge vforkdone1 and vforkdone2 into other fork tests and reuse the same
function body fork_test().

There is an implicit enhancement in vforkdone2 that it was skipping
PTRACE_VFORK check. This test is now marked as expected failure.
PR kern/51630

Sponsored by <The NetBSD Foundation>

Cover more fork/vfork/vforkdone scenarios in ATF ptrace(2) tests

Use a shared common body for all the tests: fork1..fork8, vfork1..vfork8.=
Merge vforkdone1 and vforkdone2 into vfork* tests.

All the (v?)fork[1-8] tests cover:
- calling either fork(2) or vfork(2)
- tracking either enabled or disabled FORK, VFORK or VFORK_DONE

All the PTRACE_VFORK tests are marked as expected failure.

Sponsored by <The NetBSD Foundation>
 1.1.4.2  26-Apr-2017  pgoyette Sync with HEAD
 1.1.4.1  02-Apr-2017  pgoyette file t_ptrace_wait.h was added on branch pgoyette-localcount on 2017-04-26 02:53:33 +0000
 1.1.2.2  21-Apr-2017  bouyer Sync with HEAD
 1.1.2.1  02-Apr-2017  bouyer file t_ptrace_wait.h was added on branch bouyer-socketcan on 2017-04-21 16:54:11 +0000
 1.11.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11.2.1  10-Jun-2019  christos Sync with HEAD
 1.32.4.1  31-May-2021  cjep sync with head
 1.36.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed