Re: CVS commit: src/tests/lib/libc/sys

2020-06-22 Thread Rin Okuyama

Committed. Thank you for your comment!

rin

On 2020/06/22 20:09, Kamil Rytarowski wrote:

On 22.06.2020 04:51, Rin Okuyama wrote:

Module Name:src
Committed By:   rin
Date:   Mon Jun 22 02:51:07 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_signal_wait.h t_ptrace_wait.h

Log Message:
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.




The intention of this test is just detecting SIGFPE. If the si_code
value is various on different architectures (like one traps on integers
other one on floats), we shall just drop the asserts for si_code and
adapt the trigger_fpe() function to cover promptly more ports.

The qemu bug should be fixed nonetheless.




Re: CVS commit: src/tests/lib/libc/sys

2020-06-22 Thread Kamil Rytarowski
On 22.06.2020 04:51, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Mon Jun 22 02:51:07 UTC 2020
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_signal_wait.h t_ptrace_wait.h
> 
> Log Message:
> 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.
> 


The intention of this test is just detecting SIGFPE. If the si_code
value is various on different architectures (like one traps on integers
other one on floats), we shall just drop the asserts for si_code and
adapt the trigger_fpe() function to cover promptly more ports.

The qemu bug should be fixed nonetheless.




signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-06-17 Thread Rin Okuyama

On 2020/06/17 17:42, Rin Okuyama wrote:

Now, all *_crash_fpe tests pass for powerpc, and nothing changes for amd64
at least.


Here, powerpc means powerpc/oea, more specifically Mac mini G4.

At the moment, fenv.h doesn't work correctly on booke and ibm4xx, where FPU
is emulated in software. For some processors of oea, m[ft]msr instructions
used in fenv.h may be privileged, and need similar care as booke/ibm4xx.

Thanks,
rin


Re: CVS commit: src/tests/lib/libc/sys

2020-06-06 Thread Andrew Doran
On Sat, Jun 06, 2020 at 06:11:21PM +, Jason R Thorpe wrote:

> Module Name:  src
> Committed By: thorpej
> Date: Sat Jun  6 18:11:21 UTC 2020
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_lwp_create.c
> 
> Log Message:
> Add a test case to ensure that _lwp_create() fails with the
> expected error code when a bad new-lwp-id pointer is passed.

Was thinking of just this yesterday - thanks!  It's a fragile bit of code
and has been fixed 3x already this year.

Andrew


Re: CVS commit: src/tests/lib/libc/sys

2020-05-15 Thread Kamil Rytarowski
On 15.05.2020 00:43, Taylor R Campbell wrote:
>> Date: Thu, 14 May 2020 23:36:28 +0200
>> From: Kamil Rytarowski 
>>
>> If a signal would not reach the child process (as it is ignored or
>> masked+SA_IGNOREd) and it is not a crash signal, it is dropped. As I
>> checked, it's the design in UNIX to overlook SIGCHLD signals in UNIX.
>> Race free signals could be maybe possible, but with some design rethinking.
> 
> I don't understand -- are you saying that if I mask SIGCHLD, e.g. with
> sigprocmask(SIG_BLOCK), then because sigprop[SIGCHLD] has SA_IGNORE
> set, any SIGCHLD signals will be discarded while I have it masked?
> 

That's it. But it will be discarded only when there is no SIGCHLD signal
handler installed. That's the case in the test.

A debugger catches regular signals only (except crash related ones) when
they reach the debuggee,

> This can't be right, so either I misunderstood what you're saying, or
> something else is afoot with the test that is making it flaky, or
> there's a bug in the kernel.
> 

It's a design.

If we install a signal handler for SIGCHLD in the traced the test is
very stable and we note SIGCHLD always, so there is no bug.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-05-14 Thread Taylor R Campbell
> Date: Thu, 14 May 2020 23:36:28 +0200
> From: Kamil Rytarowski 
> 
> If a signal would not reach the child process (as it is ignored or
> masked+SA_IGNOREd) and it is not a crash signal, it is dropped. As I
> checked, it's the design in UNIX to overlook SIGCHLD signals in UNIX.
> Race free signals could be maybe possible, but with some design rethinking.

I don't understand -- are you saying that if I mask SIGCHLD, e.g. with
sigprocmask(SIG_BLOCK), then because sigprop[SIGCHLD] has SA_IGNORE
set, any SIGCHLD signals will be discarded while I have it masked?

This can't be right, so either I misunderstood what you're saying, or
something else is afoot with the test that is making it flaky, or
there's a bug in the kernel.


Re: CVS commit: src/tests/lib/libc/sys

2020-05-14 Thread Joerg Sonnenberger
On Thu, May 14, 2020 at 11:36:28PM +0200, Kamil Rytarowski wrote:
> On 14.05.2020 23:02, Joerg Sonnenberger wrote:
> > On Thu, May 14, 2020 at 07:21:35PM +, Kamil Rytarowski wrote:
> >> Module Name:   src
> >> Committed By:  kamil
> >> Date:  Thu May 14 19:21:35 UTC 2020
> >>
> >> Modified Files:
> >>src/tests/lib/libc/sys: t_ptrace_fork_wait.h
> >>
> >> Log Message:
> >> Ignore interception of the SIGCHLD signals.
> >>
> >> SIGCHLD once blocked is discarded by the kernel as it has the
> >> SA_IGNORE property. During the fork(2) operation all signals can be
> >> shortly blocked and missed (unless there is a registered signal
> >> handler in the traced child). This leads to a race in this test if
> >> there would be an intention to catch SIGCHLD.
> > 
> > This doesn't sound right. sigprocmask and pthread_sigmask shouldn't
> > affect whether the signal handler is called, only when. Temporarily
> > masking a signal is different from setting it to SIG_IGN.
> > 
> > Joerg
> > 
> 
> I was looking into it and as there is no signal handler for SIGCHLD, the
> signal is discarded.

Sure, but that doesn't really have anything to do with signal blocking.
That's the part that is confusing.

Joerg


Re: CVS commit: src/tests/lib/libc/sys

2020-05-14 Thread Kamil Rytarowski
On 14.05.2020 23:02, Joerg Sonnenberger wrote:
> On Thu, May 14, 2020 at 07:21:35PM +, Kamil Rytarowski wrote:
>> Module Name: src
>> Committed By:kamil
>> Date:Thu May 14 19:21:35 UTC 2020
>>
>> Modified Files:
>>  src/tests/lib/libc/sys: t_ptrace_fork_wait.h
>>
>> Log Message:
>> Ignore interception of the SIGCHLD signals.
>>
>> SIGCHLD once blocked is discarded by the kernel as it has the
>> SA_IGNORE property. During the fork(2) operation all signals can be
>> shortly blocked and missed (unless there is a registered signal
>> handler in the traced child). This leads to a race in this test if
>> there would be an intention to catch SIGCHLD.
> 
> This doesn't sound right. sigprocmask and pthread_sigmask shouldn't
> affect whether the signal handler is called, only when. Temporarily
> masking a signal is different from setting it to SIG_IGN.
> 
> Joerg
> 

I was looking into it and as there is no signal handler for SIGCHLD, the
signal is discarded.

Another approach to fix the race would be to:

1. Add SIGCHLD signal handler in the traced child.
2. Explicitly masking SIGCHLD in the traced child.

If a signal would not reach the child process (as it is ignored or
masked+SA_IGNOREd) and it is not a crash signal, it is dropped. As I
checked, it's the design in UNIX to overlook SIGCHLD signals in UNIX.
Race free signals could be maybe possible, but with some design rethinking.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-05-14 Thread Joerg Sonnenberger
On Thu, May 14, 2020 at 07:21:35PM +, Kamil Rytarowski wrote:
> Module Name:  src
> Committed By: kamil
> Date: Thu May 14 19:21:35 UTC 2020
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_fork_wait.h
> 
> Log Message:
> Ignore interception of the SIGCHLD signals.
> 
> SIGCHLD once blocked is discarded by the kernel as it has the
> SA_IGNORE property. During the fork(2) operation all signals can be
> shortly blocked and missed (unless there is a registered signal
> handler in the traced child). This leads to a race in this test if
> there would be an intention to catch SIGCHLD.

This doesn't sound right. sigprocmask and pthread_sigmask shouldn't
affect whether the signal handler is called, only when. Temporarily
masking a signal is different from setting it to SIG_IGN.

Joerg


Re: CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Robert Elz
Date:Mon, 11 May 2020 13:47:45 +0200
From:Kamil Rytarowski 
Message-ID:  <54178983-82d1-df3d-fd54-549a6c73f...@gmx.com>

  | The only purpose of the test is to check whether misaligned program
  | counter can crash the kernel (it can for NetBSD/sparc). Later, if a
  | process dies or runs is not important, thus it is being killed.

That's all fine.

  | A process can disappear after dying and before reappearing as a zombie.

There's a state between running and dead (zombie), that's correct - but
it really doesn't matter, once the process ceases to be alive, it is beyond
killing any more.

  | This is not a bug, but a predicted race.

Yes, that's what I said, and that's fine too.

  | Doing the kill once (and missing the process) is still possibly enough,
  | but correcting it with SIGKILL does not cost.

No, there is no problem with doing the SIGKILL, but if fails for the
above reason, there's absolutely no point trying again.  The process is
gone, it isn't coming back.   It doesn't need killing.

But even if there was a reason to try again (there isn't), one more
attempt would do - inserting an infinite loop is folly.

But I see that you have fixed it, that's good, what's there now looks
much better.   Thanks.

kre




Re: CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Kamil Rytarowski
On 11.05.2020 13:35, Robert Elz wrote:
> Date:Mon, 11 May 2020 11:03:15 +
> From:"Kamil Rytarowski" 
> Message-ID:  <2020050315.54b13f...@cvs.netbsd.org>
> 
>   | Do not fail when trying to kill a dying process
>   |
>   | A dying process can disappear for a while. Rather than aborting, retry
>   | sending SIGKILL to it.
> 
> I don't understand this ... a process should never be able to
> disappear and then reappear (not in any way).   If a SIGKILL (or
> ptrace(PT_KILL) fails with a "no such process" error, then repeating
> it won't (or shouldn't) help - if it does, there's a kernel bug that
> needs fixing (and it is OK for the test to fail until that happens.)
> 
> Further, if the reason for this failure is that the process is
> dying, you probably never needed the kill in the first place (and
> no, I don't mean it should be deleted - the parent is unlikely to
> know the state of the child, so killing it, if that is what is needed
> is the right thing to do ... just that if the kill fails because you
> were too late issuing it, it isn't an error, just a race that you lost,
> and certainly shouldn't be repeated).
> 
> But more than that, adding an infinite loop to the test, where you keep
> doing the kill forever until it succeeds, or errno somehow stops being
> ESRCH looks like a recipe for disaster.
> 
> Just do the kill once, ignore the error if it is ESRCH (and probably
> also ECHILD) report other errors as failures.
> 
> kre
> 

The only purpose of the test is to check whether misaligned program
counter can crash the kernel (it can for NetBSD/sparc). Later, if a
process dies or runs is not important, thus it is being killed.

A process can disappear after dying and before reappearing as a zombie.
This is not a bug, but a predicted race. We already discussed it in the
past, whether to return the same process multiple times or overlook it
for a while during the transition dying->zombie. Once an entity died it
disappeared so the same is true for a process.

Doing the kill once (and missing the process) is still possibly enough,
but correcting it with SIGKILL does not cost.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Robert Elz
Date:Mon, 11 May 2020 11:03:15 +
From:"Kamil Rytarowski" 
Message-ID:  <2020050315.54b13f...@cvs.netbsd.org>

  | Do not fail when trying to kill a dying process
  |
  | A dying process can disappear for a while. Rather than aborting, retry
  | sending SIGKILL to it.

I don't understand this ... a process should never be able to
disappear and then reappear (not in any way).   If a SIGKILL (or
ptrace(PT_KILL) fails with a "no such process" error, then repeating
it won't (or shouldn't) help - if it does, there's a kernel bug that
needs fixing (and it is OK for the test to fail until that happens.)

Further, if the reason for this failure is that the process is
dying, you probably never needed the kill in the first place (and
no, I don't mean it should be deleted - the parent is unlikely to
know the state of the child, so killing it, if that is what is needed
is the right thing to do ... just that if the kill fails because you
were too late issuing it, it isn't an error, just a race that you lost,
and certainly shouldn't be repeated).

But more than that, adding an infinite loop to the test, where you keep
doing the kill forever until it succeeds, or errno somehow stops being
ESRCH looks like a recipe for disaster.

Just do the kill once, ignore the error if it is ESRCH (and probably
also ECHILD) report other errors as failures.

kre



Re: CVS commit: src/tests/lib/libc/sys

2020-04-24 Thread Kamil Rytarowski
On 24.04.2020 05:25, Jason R Thorpe wrote:
> Module Name:  src
> Committed By: thorpej
> Date: Fri Apr 24 03:25:20 UTC 2020
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_x86_wait.h
> 
> Log Message:
> Update for new LWP behavior -- as of 9.99.59, the LWP ID of a single-LWP
> process is the PID, not 1.
> 

Thanks. These tests shall not rely on specific LWP numbers and I will
remove the asserts.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-03-07 Thread Christos Zoulas
In article <5e528f7a-147a-23e7-46da-6b02d76e5...@gmx.com>,
Kamil Rytarowski   wrote:
>-=-=-=-=-=-
>-=-=-=-=-=-
>
>On 07.03.2020 15:53, Christos Zoulas wrote:
>> Module Name: src
>> Committed By:christos
>> Date:Sat Mar  7 14:53:14 UTC 2020
>> 
>> Modified Files:
>>  src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_wait.h
>> 
>> Log Message:
>> 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.
>> 
>> 
>
>What build configuration was broken?

All of the evbarm ones since t_ptrace_sigchld.c was not including ieefp.h
http://releng.netbsd.org/builds/HEAD/202003070040Z/evbarm-earmhfeb.build.failed

christos



Re: CVS commit: src/tests/lib/libc/sys

2020-03-07 Thread Kamil Rytarowski
On 07.03.2020 15:53, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Sat Mar  7 14:53:14 UTC 2020
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_wait.h
> 
> Log Message:
> 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.
> 
> 

What build configuration was broken?



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-02-18 Thread Kamil Rytarowski
On 18.02.2020 16:57, Christos Zoulas wrote:
> In article <20200213152742.081a9f...@cvs.netbsd.org>,
> MichaŠ Górny   wrote:
>> -=-=-=-=-=-
>>
>> Module Name: src
>> Committed By:mgorny
>> Date:Thu Feb 13 15:27:41 UTC 2020
>>
>> Modified Files:
>>  src/tests/lib/libc/sys: t_ptrace_wait.c
>>
>> Log Message:
>> Enable combined breakpoint, watchpoint and signal tests
> 
> Let's split this file up. The name does not reflect anymore what this
> is testing and it has become more than 9000 lines long. Because of the
> complexity it keeps breaking the build and because of the size it makes
> fixing it awkward. Kamil/Michal, can you please work on this?
> [ for example the llvm builds are currently broken ]
> 
> Thanks,
> 
> christos
> 

I will do it.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2020-02-18 Thread Christos Zoulas
In article <20200213152742.081a9f...@cvs.netbsd.org>,
MichaŠ Górny   wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  mgorny
>Date:  Thu Feb 13 15:27:41 UTC 2020
>
>Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_wait.c
>
>Log Message:
>Enable combined breakpoint, watchpoint and signal tests

Let's split this file up. The name does not reflect anymore what this
is testing and it has become more than 9000 lines long. Because of the
complexity it keeps breaking the build and because of the size it makes
fixing it awkward. Kamil/Michal, can you please work on this?
[ for example the llvm builds are currently broken ]

Thanks,

christos



Re: CVS commit: src/tests/lib/libc/sys

2020-02-13 Thread Christos Zoulas
In article <20200213114904.ga30...@bec.de>,
Joerg Sonnenberger   wrote:
>On Thu, Feb 13, 2020 at 10:50:19AM +0100, Joerg Sonnenberger wrote:
>> On Wed, Feb 12, 2020 at 09:53:46PM -0500, Christos Zoulas wrote:
>> > Module Name:   src
>> > Committed By:  christos
>> > Date:  Thu Feb 13 02:53:46 UTC 2020
>> > 
>> > Modified Files:
>> >src/tests/lib/libc/sys: t_ptrace_x86_wait.h
>> > 
>> > Log Message:
>> > Turn off optimization on a function which contains constant labels.
>> > The optimizer splits it and we end up with 2 copies and duplicate symbols.
>> 
>> Why not just turn them into local labels instead?
>
>Alternatively, suffixing them with %= would create unique labels.

I was looking for that :-)

christos



Re: CVS commit: src/tests/lib/libc/sys

2020-02-13 Thread Christos Zoulas
In article <20200213095019.ga28...@bec.de>,
Joerg Sonnenberger   wrote:
>On Wed, Feb 12, 2020 at 09:53:46PM -0500, Christos Zoulas wrote:
>> Module Name: src
>> Committed By:christos
>> Date:Thu Feb 13 02:53:46 UTC 2020
>> 
>> Modified Files:
>>  src/tests/lib/libc/sys: t_ptrace_x86_wait.h
>> 
>> Log Message:
>> Turn off optimization on a function which contains constant labels.
>> The optimizer splits it and we end up with 2 copies and duplicate symbols.
>
>Why not just turn them into local labels instead?

You mean 1f etc? I was not sure if that would work in the symbol defined case.

christos



Re: CVS commit: src/tests/lib/libc/sys

2020-02-13 Thread Joerg Sonnenberger
On Thu, Feb 13, 2020 at 10:50:19AM +0100, Joerg Sonnenberger wrote:
> On Wed, Feb 12, 2020 at 09:53:46PM -0500, Christos Zoulas wrote:
> > Module Name:src
> > Committed By:   christos
> > Date:   Thu Feb 13 02:53:46 UTC 2020
> > 
> > Modified Files:
> > src/tests/lib/libc/sys: t_ptrace_x86_wait.h
> > 
> > Log Message:
> > Turn off optimization on a function which contains constant labels.
> > The optimizer splits it and we end up with 2 copies and duplicate symbols.
> 
> Why not just turn them into local labels instead?

Alternatively, suffixing them with %= would create unique labels.

Joerg


Re: CVS commit: src/tests/lib/libc/sys

2020-02-13 Thread Joerg Sonnenberger
On Wed, Feb 12, 2020 at 09:53:46PM -0500, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Thu Feb 13 02:53:46 UTC 2020
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_x86_wait.h
> 
> Log Message:
> Turn off optimization on a function which contains constant labels.
> The optimizer splits it and we end up with 2 copies and duplicate symbols.

Why not just turn them into local labels instead?

Joerg


CVS commit: src/tests/lib/libc/sys

2019-11-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 12 18:18:04 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_wait.h

Log Message:
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 , tested and tweaked by myself.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/tests/lib/libc/sys/t_ptrace_wait.c
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libc/sys/t_ptrace_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libc/sys

2019-11-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 12 18:18:04 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_wait.h

Log Message:
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 , tested and tweaked by myself.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/tests/lib/libc/sys/t_ptrace_wait.c
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libc/sys/t_ptrace_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.140 src/tests/lib/libc/sys/t_ptrace_wait.c:1.141
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.140	Mon Oct 21 18:36:08 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue Nov 12 18:18:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.140 2019/10/21 18:36:08 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.141 2019/11/12 18:18:04 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.140 2019/10/21 18:36:08 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.141 2019/11/12 18:18:04 kamil Exp $");
 
 #include 
 #include 
@@ -5478,7 +5478,7 @@ trace_threads(bool trace_create, bool tr
 	lwpid_t lid;
 
 	/* Track created and exited threads */
-	bool traced_lwps[__arraycount(t)];
+	struct lwp_event_count traced_lwps[__arraycount(t)] = {{0, 0}};
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
@@ -5541,8 +5541,6 @@ trace_threads(bool trace_create, bool tr
 	"without signal to be sent\n");
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 
-	memset(traced_lwps, 0, sizeof(traced_lwps));
-
 	for (n = 0; n < (trace_create ? __arraycount(t) : 0); n++) {
 		DPRINTF("Before calling %s() for the child - expected stopped "
 		"SIGTRAP\n", TWAIT_FNAME);
@@ -5574,7 +5572,7 @@ trace_threads(bool trace_create, bool tr
 		lid = state.pe_lwp;
 		DPRINTF("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
 
-		traced_lwps[lid - 1] = true;
+		*FIND_EVENT_COUNT(traced_lwps, lid) += 1;
 
 		DPRINTF("Before resuming the child process where it left off "
 		"and without signal to be sent\n");
@@ -5613,8 +5611,9 @@ trace_threads(bool trace_create, bool tr
 		DPRINTF("Reported PTRACE_LWP_EXIT event with lid %d\n", lid);
 
 		if (trace_create) {
-			ATF_REQUIRE(traced_lwps[lid - 1] == true);
-			traced_lwps[lid - 1] = false;
+			int *count = FIND_EVENT_COUNT(traced_lwps, lid);
+			ATF_REQUIRE_EQ(*count, 1);
+			*count = 0;
 		}
 
 		DPRINTF("Before resuming the child process where it left off "
@@ -7738,7 +7737,8 @@ ATF_TC_BODY(thread_concurrent_signals, t
 	const int sigval = SIGSTOP;
 	pid_t child, wpid;
 	int status;
-	int signal_counts[THREAD_CONCURRENT_SIGNALS_NUM] = {0};
+	struct lwp_event_count signal_counts[THREAD_CONCURRENT_SIGNALS_NUM]
+	= {{0, 0}};
 	unsigned int i;
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
@@ -7816,21 +7816,16 @@ ATF_TC_BODY(thread_concurrent_signals, t
 		"lwp=%d, expected %d, got %d", info.psi_lwpid,
 		expected_sig, WSTOPSIG(status));
 
-		/* We assume that LWPs will be given successive numbers starting
-		 * from 2.
-		 */
-		ATF_REQUIRE(info.psi_lwpid >= 2);
-		ATF_REQUIRE((unsigned int)info.psi_lwpid <
-		__arraycount(signal_counts)+2);
-		signal_counts[info.psi_lwpid-2]++;
+		*FIND_EVENT_COUNT(signal_counts, info.psi_lwpid) += 1;
 
 		DPRINTF("Before resuming the child process\n");
 		SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 	}
 
 	for (i = 0; i < __arraycount(signal_counts); i++)
-		ATF_CHECK_EQ_MSG(signal_counts[i], 1, "signal_counts[%d]=%d",
-		i, signal_counts[i]);
+		ATF_CHECK_EQ_MSG(signal_counts[i].lec_count, 1,
+		"signal_counts[%d].lec_count=%d; lec_lwp=%d",
+		i, signal_counts[i].lec_count, signal_counts[i].lec_lwp);
 
 	validate_status_exited(status, exitval);
 }

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.17 src/tests/lib/libc/sys/t_ptrace_wait.h:1.18
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.17	Sat May 25 03:22:53 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Tue Nov 12 18:18:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.17 2019/05/25 03:22:53 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.18 2019/11/12 18:18:04 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -674,6 +674,30 @@ trigger_bus(void)
 	*p = 'a';
 }
 
+struct lwp_event_count {
+	lwpid_t lec_lwp;
+	int lec_count;
+};
+
+static int *
+find_event_count(struct lwp_event_count list[], lwpid_t lwp, size_t max_lwps)
+{
+	size_t i;
+
+	for (i = 0; i < max_lwps; i++) {
+		

CVS commit: src/tests/lib/libc/sys

2019-10-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Oct 21 18:36:08 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
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.139 -r1.140 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.139 src/tests/lib/libc/sys/t_ptrace_wait.c:1.140
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.139	Mon Oct 21 18:31:40 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon Oct 21 18:36:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.139 2019/10/21 18:31:40 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.140 2019/10/21 18:36:08 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.139 2019/10/21 18:31:40 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.140 2019/10/21 18:36:08 kamil Exp $");
 
 #include 
 #include 
@@ -121,10 +121,6 @@ static int debug = 0;
 	printf("%s() %s:%d " a, __func__, __FILE__, __LINE__,  ##__VA_ARGS__); \
 while (/*CONSTCOND*/0)
 
-#ifndef TEST_LWP_ENABLED
-#define TEST_LWP_ENABLED 1
-#endif
-
 /// 
 
 static void
@@ -5484,11 +5480,6 @@ trace_threads(bool trace_create, bool tr
 	/* Track created and exited threads */
 	bool traced_lwps[__arraycount(t)];
 
-#if !TEST_LWP_ENABLED
-	if (trace_create || trace_exit)
-		atf_tc_skip("PR kern/51995");
-#endif
-
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {



CVS commit: src/tests/lib/libc/sys

2019-10-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Oct 21 18:36:08 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
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.139 -r1.140 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.



CVS commit: src/tests/lib/libc/sys

2019-10-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Oct 21 18:31:40 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Remove preprocessor switch TEST_VFORK_ENABLED in t_ptrace_wait*

vfork(2) tests are now enabled always and confirmed to be stable.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 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.



CVS commit: src/tests/lib/libc/sys

2019-10-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Oct 21 18:31:40 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Remove preprocessor switch TEST_VFORK_ENABLED in t_ptrace_wait*

vfork(2) tests are now enabled always and confirmed to be stable.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.138 src/tests/lib/libc/sys/t_ptrace_wait.c:1.139
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.138	Mon Oct 21 17:07:00 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon Oct 21 18:31:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.138 2019/10/21 17:07:00 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.139 2019/10/21 18:31:40 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.138 2019/10/21 17:07:00 mgorny Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.139 2019/10/21 18:31:40 kamil Exp $");
 
 #include 
 #include 
@@ -121,10 +121,6 @@ static int debug = 0;
 	printf("%s() %s:%d " a, __func__, __FILE__, __LINE__,  ##__VA_ARGS__); \
 while (/*CONSTCOND*/0)
 
-#ifndef TEST_VFORK_ENABLED
-#define TEST_VFORK_ENABLED 1
-#endif
-
 #ifndef TEST_LWP_ENABLED
 #define TEST_LWP_ENABLED 1
 #endif
@@ -3269,7 +3265,6 @@ FORK_TEST(fork15, "fork", true, false, t
 FORK_TEST(fork16, "fork", true, true, true, true)
 #endif
 
-#if TEST_VFORK_ENABLED
 FORK_TEST(vfork1, "vfork", false, false, false, false)
 #if defined(TWAIT_HAVE_PID)
 FORK_TEST(vfork2, "vfork", false, true, false, false)
@@ -3294,7 +3289,6 @@ FORK_TEST(vfork14, "vfork", true, true, 
 FORK_TEST(vfork15, "vfork", true, false, true, true)
 FORK_TEST(vfork16, "vfork", true, true, true, true)
 #endif
-#endif
 
 FORK_TEST(posix_spawn1, "spawn", false, false, false, false)
 FORK_TEST(posix_spawn2, "spawn", false, true, false, false)
@@ -3497,22 +3491,17 @@ ATF_TC_BODY(name, tc)			\
 
 FORK_DETACH_FORKER(posix_spawn_detach_spawner, "spawn", false)
 FORK_DETACH_FORKER(fork_detach_forker, "fork", false)
-#if TEST_VFORK_ENABLED
 FORK_DETACH_FORKER(vfork_detach_vforker, "vfork", false)
 FORK_DETACH_FORKER(vfork_detach_vforkerdone, "vforkdone", false)
-#endif
 
 FORK_DETACH_FORKER(posix_spawn_kill_spawner, "spawn", true)
 FORK_DETACH_FORKER(fork_kill_forker, "fork", true)
-#if TEST_VFORK_ENABLED
 FORK_DETACH_FORKER(vfork_kill_vforker, "vfork", true)
 FORK_DETACH_FORKER(vfork_kill_vforkerdone, "vforkdone", true)
 #endif
-#endif
 
 /// 
 
-#if TEST_VFORK_ENABLED
 static void
 traceme_vfork_fork_body(pid_t (*fn)(void))
 {
@@ -3571,7 +3560,6 @@ ATF_TC_BODY(name, tc)			\
 
 TRACEME_VFORK_FORK_TEST(traceme_vfork_fork, fork)
 TRACEME_VFORK_FORK_TEST(traceme_vfork_vfork, vfork)
-#endif
 
 /// 
 
@@ -6126,13 +6114,11 @@ FORK2_TEST(posix_spawn_singalmasked, "sp
 FORK2_TEST(posix_spawn_singalignored, "spawn", false, true)
 FORK2_TEST(fork_singalmasked, "fork", true, false)
 FORK2_TEST(fork_singalignored, "fork", false, true)
-#if TEST_VFORK_ENABLED
 FORK2_TEST(vfork_singalmasked, "vfork", true, false)
 FORK2_TEST(vfork_singalignored, "vfork", false, true)
 FORK2_TEST(vforkdone_singalmasked, "vforkdone", true, false)
 FORK2_TEST(vforkdone_singalignored, "vforkdone", false, true)
 #endif
-#endif
 
 /// 
 
@@ -6991,7 +6977,6 @@ CLONE_TEST(clone_files8, CLONE_FILES, tr
 //CLONE_TEST(clone_sighand8, CLONE_SIGHAND, true, true, true)
 #endif
 
-#if TEST_VFORK_ENABLED
 CLONE_TEST(clone_vfork1, CLONE_VFORK, false, false, false)
 #if defined(TWAIT_HAVE_PID)
 CLONE_TEST(clone_vfork2, CLONE_VFORK, true, false, false)
@@ -7004,7 +6989,6 @@ CLONE_TEST(clone_vfork6, CLONE_VFORK, tr
 CLONE_TEST(clone_vfork7, CLONE_VFORK, false, true, true)
 CLONE_TEST(clone_vfork8, CLONE_VFORK, true, true, true)
 #endif
-#endif
 
 /// 
 
@@ -7367,15 +7351,12 @@ CLONE_TEST2(clone_files_signalignored, C
 CLONE_TEST2(clone_files_signalmasked, CLONE_FILES, false, true)
 //CLONE_TEST2(clone_sighand_signalignored, CLONE_SIGHAND, true, false) // XXX
 //CLONE_TEST2(clone_sighand_signalmasked, CLONE_SIGHAND, false, true)  // XXX
-#if TEST_VFORK_ENABLED
 CLONE_TEST2(clone_vfork_signalignored, CLONE_VFORK, true, false)
 CLONE_TEST2(clone_vfork_signalmasked, CLONE_VFORK, false, true)
 #endif
-#endif
 
 /// 
 
-#if TEST_VFORK_ENABLED
 #if defined(TWAIT_HAVE_PID)
 static void
 traceme_vfork_clone_body(int 

CVS commit: src/tests/lib/libc/sys

2019-10-13 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Oct 13 09:42:15 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Fix race in t_ptrace_wait* LWP tests

Increment the done variable under a mutex. This variable was updated
non-atomically and sometimes not reaching the expected treshold.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.136 src/tests/lib/libc/sys/t_ptrace_wait.c:1.137
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.136	Sun Oct 13 04:05:39 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Oct 13 09:42:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.136 2019/10/13 04:05:39 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.137 2019/10/13 09:42:15 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.136 2019/10/13 04:05:39 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.137 2019/10/13 09:42:15 kamil Exp $");
 
 #include 
 #include 
@@ -5458,12 +5458,15 @@ TRACEME_EXEC(traceme_signalignored_exec,
 #define TRACE_THREADS_NUM 100
 
 static volatile int done;
+pthread_mutex_t trace_threads_mtx = PTHREAD_MUTEX_INITIALIZER;
 
 static void *
 trace_threads_cb(void *arg __unused)
 {
 
+	pthread_mutex_lock(_threads_mtx);
 	done++;
+	pthread_mutex_unlock(_threads_mtx);
 
 	while (done < TRACE_THREADS_NUM)
 		sched_yield();



CVS commit: src/tests/lib/libc/sys

2019-10-13 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Oct 13 09:42:15 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Fix race in t_ptrace_wait* LWP tests

Increment the done variable under a mutex. This variable was updated
non-atomically and sometimes not reaching the expected treshold.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 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.



CVS commit: src/tests/lib/libc/sys

2019-10-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Oct 13 04:05:39 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.135 src/tests/lib/libc/sys/t_ptrace_wait.c:1.136
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.135	Sun Oct 13 04:00:12 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Oct 13 04:05:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.135 2019/10/13 04:00:12 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.136 2019/10/13 04:05:39 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.135 2019/10/13 04:00:12 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.136 2019/10/13 04:05:39 kamil Exp $");
 
 #include 
 #include 
@@ -126,7 +126,7 @@ static int debug = 0;
 #endif
 
 #ifndef TEST_LWP_ENABLED
-#define TEST_LWP_ENABLED 0
+#define TEST_LWP_ENABLED 1
 #endif
 
 /// 



CVS commit: src/tests/lib/libc/sys

2019-10-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Oct 13 04:05:39 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 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.



CVS commit: src/tests/lib/libc/sys

2019-10-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Oct 13 04:00:12 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Bump the number of threads in LWP t_ptrace_wait*() tests from to 100

This is a torture, but on purpose to catch LWP_CREATED and LWP_EXITED bugs.
The threads do nothing other than calling sched_yield() in a loop.

MAXLWP is now defined to 2048 on all ports.

This change effects the following tests:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 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.



CVS commit: src/tests/lib/libc/sys

2019-10-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Oct 13 04:00:12 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Bump the number of threads in LWP t_ptrace_wait*() tests from to 100

This is a torture, but on purpose to catch LWP_CREATED and LWP_EXITED bugs.
The threads do nothing other than calling sched_yield() in a loop.

MAXLWP is now defined to 2048 on all ports.

This change effects the following tests:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.134 src/tests/lib/libc/sys/t_ptrace_wait.c:1.135
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.134	Wed Oct  2 23:15:09 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Oct 13 04:00:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.134 2019/10/02 23:15:09 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.135 2019/10/13 04:00:12 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.134 2019/10/02 23:15:09 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.135 2019/10/13 04:00:12 kamil Exp $");
 
 #include 
 #include 
@@ -5455,6 +5455,8 @@ TRACEME_EXEC(traceme_signalignored_exec,
 
 /// 
 
+#define TRACE_THREADS_NUM 100
+
 static volatile int done;
 
 static void *
@@ -5463,8 +5465,8 @@ trace_threads_cb(void *arg __unused)
 
 	done++;
 
-	while (done < 3)
-		continue;
+	while (done < TRACE_THREADS_NUM)
+		sched_yield();
 
 	return NULL;
 }
@@ -5483,7 +5485,7 @@ trace_threads(bool trace_create, bool tr
 	const int elen = sizeof(event);
 	struct ptrace_siginfo info;
 
-	pthread_t t[3];
+	pthread_t t[TRACE_THREADS_NUM];
 	int rv;
 	size_t n;
 	lwpid_t lid;



CVS commit: src/tests/lib/libc/sys

2019-10-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Oct  2 23:15:09 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Remove ATF t_ptrace_wait test suspend1

The tests verifies that a thread can be suspended by a debugger and later
resumed by a tracee.

This is an unwanted behavior and will be fixed soon.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.133 src/tests/lib/libc/sys/t_ptrace_wait.c:1.134
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.133	Tue Oct  1 22:26:38 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Wed Oct  2 23:15:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.133 2019/10/01 22:26:38 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.134 2019/10/02 23:15:09 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.133 2019/10/01 22:26:38 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.134 2019/10/02 23:15:09 kamil Exp $");
 
 #include 
 #include 
@@ -6354,133 +6354,6 @@ lwp_main_stop(void *arg)
 	_lwp_exit();
 }
 
-ATF_TC(suspend1);
-ATF_TC_HEAD(suspend1, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	"Verify that a thread can be suspended by a debugger and later "
-	"resumed by a tracee");
-}
-
-ATF_TC_BODY(suspend1, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	ucontext_t uc;
-	lwpid_t lid;
-	static const size_t ssize = 16*1024;
-	void *stack;
-	struct ptrace_lwpinfo pl;
-	struct ptrace_siginfo psi;
-	volatile int go = 0;
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		DPRINTF("Before allocating memory for stack in child\n");
-		FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
-
-		DPRINTF("Before making context for new lwp in child\n");
-		_lwp_makecontext(, lwp_main_stop, NULL, NULL, stack, ssize);
-
-		DPRINTF("Before creating new in child\n");
-		FORKEE_ASSERT(_lwp_create(, 0, ) == 0);
-
-		while (go == 0)
-			continue;
-
-		raise(SIGINT);
-
-		FORKEE_ASSERT(_lwp_continue(lid) == 0);
-
-		DPRINTF("Before waiting for lwp %d to exit\n", lid);
-		FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
-
-		DPRINTF("Before verifying that reported %d and running lid %d "
-		"are the same\n", lid, the_lwp_id);
-		FORKEE_ASSERT_EQ(lid, the_lwp_id);
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-	DPRINTF("Before calling %s() for the child - expected stopped "
-	"SIGTRAP\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, SIGTRAP);
-
-	DPRINTF("Before reading siginfo and lwpid_t\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, , sizeof(psi)) != -1);
-
-	DPRINTF("Before suspending LWP %d\n", psi.psi_lwpid);
-	SYSCALL_REQUIRE(ptrace(PT_SUSPEND, child, NULL, psi.psi_lwpid) != -1);
-
-DPRINTF("Write new go to tracee (PID=%d) from tracer (PID=%d)\n",
-	child, getpid());
-	SYSCALL_REQUIRE(ptrace(PT_WRITE_D, child, __UNVOLATILE(), 1) != -1);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-	DPRINTF("Before calling %s() for the child - expected stopped "
-	"SIGINT\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, SIGINT);
-
-	pl.pl_lwpid = 0;
-
-	SYSCALL_REQUIRE(ptrace(PT_LWPINFO, child, , sizeof(pl)) != -1);
-	while (pl.pl_lwpid != 0) {
-
-		SYSCALL_REQUIRE(ptrace(PT_LWPINFO, child, , sizeof(pl)) != -1);
-		switch (pl.pl_lwpid) {
-		case 1:
-			ATF_REQUIRE_EQ(pl.pl_event, PL_EVENT_SIGNAL);
-			break;
-		case 2:
-			ATF_REQUIRE_EQ(pl.pl_event, PL_EVENT_SUSPENDED);
-			break;
-		}
-	}
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, 

CVS commit: src/tests/lib/libc/sys

2019-10-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Oct  2 23:15:09 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Remove ATF t_ptrace_wait test suspend1

The tests verifies that a thread can be suspended by a debugger and later
resumed by a tracee.

This is an unwanted behavior and will be fixed soon.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 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.



CVS commit: src/tests/lib/libc/sys

2019-10-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  1 22:26:38 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Merge PT_GET_PROCESS_STATE checks into traceme_raise ATF ptrace tests

Assert that PT_GET_PROCESS_STATE for !child and !lwp events returns
non-error and zeroed struct ptrace_state.

These checks are not really special to traceme_raise, it's just an
opportunity to reuse them in an existing tests without writing a dedicated
one.

This behavior is needed to maintain in 3rd party software (GDB).


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 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.



CVS commit: src/tests/lib/libc/sys

2019-10-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  1 22:26:38 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Merge PT_GET_PROCESS_STATE checks into traceme_raise ATF ptrace tests

Assert that PT_GET_PROCESS_STATE for !child and !lwp events returns
non-error and zeroed struct ptrace_state.

These checks are not really special to traceme_raise, it's just an
opportunity to reuse them in an existing tests without writing a dedicated
one.

This behavior is needed to maintain in 3rd party software (GDB).


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.132 src/tests/lib/libc/sys/t_ptrace_wait.c:1.133
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.132	Tue Oct  1 21:13:30 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue Oct  1 22:26:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.133 2019/10/01 22:26:38 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.133 2019/10/01 22:26:38 kamil Exp $");
 
 #include 
 #include 
@@ -140,7 +140,10 @@ traceme_raise(int sigval)
 	int status;
 #endif
 
+	ptrace_state_t state, zero_state;
+	const int slen = sizeof(state);
 	struct ptrace_siginfo info;
+	memset(_state, 0, sizeof(zero_state));
 	memset(, 0, sizeof(info));
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
@@ -170,6 +173,9 @@ traceme_raise(int sigval)
 	switch (sigval) {
 	case SIGKILL:
 		validate_status_signaled(status, sigval, 0);
+		SYSCALL_REQUIRE(
+		ptrace(PT_GET_PROCESS_STATE, child, , slen) == -1);
+
 		break;
 	default:
 		validate_status_stopped(status, sigval);
@@ -188,6 +194,11 @@ traceme_raise(int sigval)
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
 
+		DPRINTF("Assert that PT_GET_PROCESS_STATE returns non-error");
+		SYSCALL_REQUIRE(
+		ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
+		ATF_REQUIRE(memcmp(, _state, slen) == 0);
+
 		DPRINTF("Before resuming the child process where it left off "
 		"and without signal to be sent\n");
 		SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);



CVS commit: src/tests/lib/libc/sys

2019-10-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  1 21:13:30 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add a few static asserts in t_ptrace_wait.c for conditions that must be kept

Assert that ptrace_state and siginfo_t's _ptrace_state are synchronized.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 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.



CVS commit: src/tests/lib/libc/sys

2019-10-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  1 21:13:30 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add a few static asserts in t_ptrace_wait.c for conditions that must be kept

Assert that ptrace_state and siginfo_t's _ptrace_state are synchronized.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.131 src/tests/lib/libc/sys/t_ptrace_wait.c:1.132
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.131	Mon Jul  1 02:04:37 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue Oct  1 21:13:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.131 2019/07/01 02:04:37 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131 2019/07/01 02:04:37 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.13
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -73,6 +74,20 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.13
 
 #include 
 
+/* Assumptions in the kernel code that must be kept. */
+static_assert(sizeof(((struct ptrace_state *)0)->pe_report_event) ==
+sizeof(((siginfo_t *)0)->si_pe_report_event),
+"pe_report_event and si_pe_report_event must be of the same size");
+static_assert(sizeof(((struct ptrace_state *)0)->pe_other_pid) ==
+sizeof(((siginfo_t *)0)->si_pe_other_pid),
+"pe_other_pid and si_pe_other_pid must be of the same size");
+static_assert(sizeof(((struct ptrace_state *)0)->pe_lwp) ==
+sizeof(((siginfo_t *)0)->si_pe_lwp),
+"pe_lwp and si_pe_lwp must be of the same size");
+static_assert(sizeof(((struct ptrace_state *)0)->pe_other_pid) ==
+sizeof(((struct ptrace_state *)0)->pe_lwp),
+"pe_other_pid and pe_lwp must be of the same size");
+
 #include "h_macros.h"
 
 #include "t_ptrace_wait.h"



CVS commit: src/tests/lib/libc/sys

2019-07-13 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jul 13 12:44:02 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_getitimer.c

Log Message:
In the setitimer_old test case, allow for time passing between the two
setitimer() calls.  Should fix PR kern/54370.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_getitimer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libc/sys

2019-07-13 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jul 13 12:44:02 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_getitimer.c

Log Message:
In the setitimer_old test case, allow for time passing between the two
setitimer() calls.  Should fix PR kern/54370.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_getitimer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_getitimer.c
diff -u src/tests/lib/libc/sys/t_getitimer.c:1.2 src/tests/lib/libc/sys/t_getitimer.c:1.3
--- src/tests/lib/libc/sys/t_getitimer.c:1.2	Thu Mar 22 18:20:46 2012
+++ src/tests/lib/libc/sys/t_getitimer.c	Sat Jul 13 12:44:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getitimer.c,v 1.2 2012/03/22 18:20:46 christos Exp $ */
+/* $NetBSD: t_getitimer.c,v 1.3 2019/07/13 12:44:02 gson Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_getitimer.c,v 1.2 2012/03/22 18:20:46 christos Exp $");
+__RCSID("$NetBSD: t_getitimer.c,v 1.3 2019/07/13 12:44:02 gson Exp $");
 
 #include 
 
@@ -175,11 +175,13 @@ ATF_TC_BODY(setitimer_old, tc)
 	struct itimerval it, ot;
 
 	/*
-	 * Make two calls; the second one
-	 * should store the old values.
+	 * Make two calls; the second one should store the old
+	 * timer value which should be the same as that set in
+	 * the first call, or slightly less due to time passing
+	 * between the two calls.
 	 */
 	it.it_value.tv_sec = 4;
-	it.it_value.tv_usec = 3;
+	it.it_value.tv_usec = 99;
 
 	it.it_interval.tv_sec = 0;
 	it.it_interval.tv_usec = 0;
@@ -194,7 +196,8 @@ ATF_TC_BODY(setitimer_old, tc)
 
 	ATF_REQUIRE(setitimer(ITIMER_REAL, , ) == 0);
 
-	if (ot.it_value.tv_sec != 4 || ot.it_value.tv_usec != 3)
+	/* Check seconds only as microseconds may have decremented */
+	if (ot.it_value.tv_sec != 4)
 		atf_tc_fail("setitimer(2) did not store old values");
 }
 



Re: CVS commit: src/tests/lib/libc/sys

2019-07-01 Thread Kamil Rytarowski
On 01.07.2019 14:59, Robert Elz wrote:
> Date:Mon, 1 Jul 2019 11:55:57 +0200
> From:Joerg Sonnenberger 
> Message-ID:  <20190701095557.ga55...@bec.de>
> 
>   | On Mon, Jul 01, 2019 at 02:04:38AM +, Kamil Rytarowski wrote:
> 
>   | > Cast note_hdr.n_namesz to ssize_t through size_t to avoid potential
>   | > signedness bit shifts.
>   |
>   | This change makes no sense.
> 
> Certainly the size_t cast is pointless ... and I have no idea what
> the comment in the commit message about bit shifts is about, this is
> (was) a simple comparison of an unsigned with a signed, which the
> cast to ssize_t turns into a signed comparison, which is as it should be.
> There are no bit shifts.
> 
> kre
> 
> 

OK, it was cast of 32bit value to ssize_t that can be 64bit.

The original type is uint32_t, not int32_t, so intermediate cast is not
needed.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2019-07-01 Thread Robert Elz
Date:Mon, 1 Jul 2019 11:55:57 +0200
From:Joerg Sonnenberger 
Message-ID:  <20190701095557.ga55...@bec.de>

  | On Mon, Jul 01, 2019 at 02:04:38AM +, Kamil Rytarowski wrote:

  | > Cast note_hdr.n_namesz to ssize_t through size_t to avoid potential
  | > signedness bit shifts.
  |
  | This change makes no sense.

Certainly the size_t cast is pointless ... and I have no idea what
the comment in the commit message about bit shifts is about, this is
(was) a simple comparison of an unsigned with a signed, which the
cast to ssize_t turns into a signed comparison, which is as it should be.
There are no bit shifts.

kre




Re: CVS commit: src/tests/lib/libc/sys

2019-07-01 Thread Joerg Sonnenberger
On Mon, Jul 01, 2019 at 02:04:38AM +, Kamil Rytarowski wrote:
> Module Name:  src
> Committed By: kamil
> Date: Mon Jul  1 02:04:38 UTC 2019
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_wait.c
> 
> Log Message:
> Avoid GCC warning on NetBSD/i386
> 
> Cast note_hdr.n_namesz to ssize_t through size_t to avoid potential
> signedness bit shifts.

This change makes no sense.

Joerg


CVS commit: src/tests/lib/libc/sys

2019-06-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jul  1 02:04:38 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Avoid GCC warning on NetBSD/i386

Cast note_hdr.n_namesz to ssize_t through size_t to avoid potential
signedness bit shifts.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.130 src/tests/lib/libc/sys/t_ptrace_wait.c:1.131
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.130	Sun Jun 30 21:20:04 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon Jul  1 02:04:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.130 2019/06/30 21:20:04 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.131 2019/07/01 02:04:37 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.130 2019/06/30 21:20:04 mgorny Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131 2019/07/01 02:04:37 kamil Exp $");
 
 #include 
 #include 
@@ -7706,7 +7706,7 @@ static ssize_t core_find_note(const char
 			note_hdr.n_namesz <= sizeof(name_buf)) {
 SYSCALL_REQUIRE(pread(core_fd, name_buf,
 note_hdr.n_namesz, offset)
-== note_hdr.n_namesz);
+== (ssize_t)(size_t)note_hdr.n_namesz);
 
 if (!strncmp(note_name, name_buf, name_len) &&
 note_hdr.n_type == note_type)



CVS commit: src/tests/lib/libc/sys

2019-06-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jul  1 02:04:38 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Avoid GCC warning on NetBSD/i386

Cast note_hdr.n_namesz to ssize_t through size_t to avoid potential
signedness bit shifts.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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.



CVS commit: src/tests/lib/libc/sys

2019-06-30 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Sun Jun 30 21:20:04 UTC 2019

Modified Files:
src/tests/lib/libc/sys: Makefile t_ptrace_wait.c

Log Message:
Add a test for verifying procinfo note inside coredumps.

Add a first test for triggering a core dump in the debugged process
(via PT_DUMPCORE) and verifying it.  The test finds procinfo note
and checks its contents.

The core dump is processed through libelf.  However, it only provides
for finding all note segments (or sections?).  I had to implement
finding and processing individual notes myself.  I've added
a core_find_note() function that will be reused in future tests.

Reviewed by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.129 -r1.130 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.



CVS commit: src/tests/lib/libc/sys

2019-06-30 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Sun Jun 30 21:20:04 UTC 2019

Modified Files:
src/tests/lib/libc/sys: Makefile t_ptrace_wait.c

Log Message:
Add a test for verifying procinfo note inside coredumps.

Add a first test for triggering a core dump in the debugged process
(via PT_DUMPCORE) and verifying it.  The test finds procinfo note
and checks its contents.

The core dump is processed through libelf.  However, it only provides
for finding all note segments (or sections?).  I had to implement
finding and processing individual notes myself.  I've added
a core_find_note() function that will be reused in future tests.

Reviewed by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.129 -r1.130 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.

Modified files:

Index: src/tests/lib/libc/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.56 src/tests/lib/libc/sys/Makefile:1.57
--- src/tests/lib/libc/sys/Makefile:1.56	Fri Apr 26 20:41:10 2019
+++ src/tests/lib/libc/sys/Makefile	Sun Jun 30 21:20:04 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.56 2019/04/26 20:41:10 maya Exp $
+# $NetBSD: Makefile,v 1.57 2019/06/30 21:20:04 mgorny Exp $
 
 MKMAN=	no
 
@@ -88,12 +88,12 @@ SRCS.t_mprotect=	t_mprotect.c ${SRCS_EXE
 
 LDADD.t_getpid+=-lpthread
 
-LDADD.t_ptrace_wait+=		-pthread -lm
-LDADD.t_ptrace_wait3+=		-pthread -lm
-LDADD.t_ptrace_wait4+=		-pthread -lm
-LDADD.t_ptrace_wait6+=		-pthread -lm
-LDADD.t_ptrace_waitid+=		-pthread -lm
-LDADD.t_ptrace_waitpid+=	-pthread -lm
+LDADD.t_ptrace_wait+=		-pthread -lm -lelf
+LDADD.t_ptrace_wait3+=		-pthread -lm -lelf
+LDADD.t_ptrace_wait4+=		-pthread -lm -lelf
+LDADD.t_ptrace_wait6+=		-pthread -lm -lelf
+LDADD.t_ptrace_waitid+=		-pthread -lm -lelf
+LDADD.t_ptrace_waitpid+=	-pthread -lm -lelf
 
 .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
 CPPFLAGS.t_posix_fadvise.c += -D_KERNTYPES

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.129 src/tests/lib/libc/sys/t_ptrace_wait.c:1.130
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.129	Wed Jun 26 12:30:13 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Jun 30 21:20:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.129 2019/06/26 12:30:13 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.130 2019/06/30 21:20:04 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,10 +27,11 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.129 2019/06/26 12:30:13 mgorny Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.130 2019/06/30 21:20:04 mgorny Exp $");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,6 +44,7 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.12
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -66,6 +68,9 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.12
 #include 
 #endif
 
+#include 
+#include 
+
 #include 
 
 #include "h_macros.h"
@@ -7639,6 +7644,180 @@ USER_VA0_DISABLE(user_va0_disable_pt_det
 
 /// 
 
+/*
+ * Parse the core file and find the requested note.  If the reading or parsing
+ * fails, the test is failed.  If the note is found, it is read onto buf, up to
+ * buf_len.  The actual length of the note is returned (which can be greater
+ * than buf_len, indicating that it has been truncated).  If the note is not
+ * found, -1 is returned.
+ */
+static ssize_t core_find_note(const char *core_path,
+const char *note_name, uint64_t note_type, void *buf, size_t buf_len)
+{
+	int core_fd;
+	Elf *core_elf;
+	size_t core_numhdr, i;
+	ssize_t ret = -1;
+	/* note: we assume note name will be null-terminated */
+	size_t name_len = strlen(note_name) + 1;
+
+	SYSCALL_REQUIRE((core_fd = open(core_path, O_RDONLY)) != -1);
+	SYSCALL_REQUIRE(elf_version(EV_CURRENT) != EV_NONE);
+	SYSCALL_REQUIRE((core_elf = elf_begin(core_fd, ELF_C_READ, NULL)));
+
+	SYSCALL_REQUIRE(elf_getphnum(core_elf, _numhdr) != 0);
+	for (i = 0; i < core_numhdr && ret == -1; i++) {
+		GElf_Phdr core_hdr;
+		size_t offset;
+		SYSCALL_REQUIRE(gelf_getphdr(core_elf, i, _hdr));
+		if (core_hdr.p_type != PT_NOTE)
+		continue;
+
+		for (offset = core_hdr.p_offset;
+		offset < core_hdr.p_offset + core_hdr.p_filesz;) {
+			Elf64_Nhdr note_hdr;
+			char name_buf[64];
+
+			switch (gelf_getclass(core_elf)) {
+			case ELFCLASS64:
+SYSCALL_REQUIRE(pread(core_fd, _hdr,
+sizeof(note_hdr), offset)
+== sizeof(note_hdr));
+offset += sizeof(note_hdr);
+break;
+			case ELFCLASS32:
+{
+Elf32_Nhdr tmp_hdr;
+SYSCALL_REQUIRE(pread(core_fd, _hdr,
+sizeof(tmp_hdr), offset)
+== sizeof(tmp_hdr));
+offset += sizeof(tmp_hdr);
+note_hdr.n_namesz = tmp_hdr.n_namesz;
+

CVS commit: src/tests/lib/libc/sys

2019-06-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun 18 21:14:26 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Allow to conditionally enable LWP ATF tests in t_ptrace_wait*

By default the tests are disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.127 src/tests/lib/libc/sys/t_ptrace_wait.c:1.128
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.127	Thu Jun 13 20:26:06 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue Jun 18 21:14:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.127 2019/06/13 20:26:06 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.128 2019/06/18 21:14:26 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.127 2019/06/13 20:26:06 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.128 2019/06/18 21:14:26 kamil Exp $");
 
 #include 
 #include 
@@ -103,6 +103,10 @@ static int debug = 0;
 #define TEST_VFORK_ENABLED 1
 #endif
 
+#ifndef TEST_LWP_ENABLED
+#define TEST_LWP_ENABLED 0
+#endif
+
 /// 
 
 static void
@@ -5454,8 +5458,10 @@ trace_threads(bool trace_create, bool tr
 	/* Track created and exited threads */
 	bool traced_lwps[__arraycount(t)];
 
+#if !TEST_LWP_ENABLED
 	if (trace_create || trace_exit)
 		atf_tc_skip("PR kern/51995");
+#endif
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);



CVS commit: src/tests/lib/libc/sys

2019-06-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun 18 21:14:26 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Allow to conditionally enable LWP ATF tests in t_ptrace_wait*

By default the tests are disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 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.



CVS commit: src/tests/lib/libc/sys

2019-06-13 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Jun 13 20:26:06 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Enable vfork(2) ATF tests in t_ptrace_wait*

The racing issues are gone in my local setup.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.126 src/tests/lib/libc/sys/t_ptrace_wait.c:1.127
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.126	Wed Jun 12 17:07:11 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Thu Jun 13 20:26:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.126 2019/06/12 17:07:11 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.127 2019/06/13 20:26:06 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.126 2019/06/12 17:07:11 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.127 2019/06/13 20:26:06 kamil Exp $");
 
 #include 
 #include 
@@ -100,7 +100,7 @@ static int debug = 0;
 while (/*CONSTCOND*/0)
 
 #ifndef TEST_VFORK_ENABLED
-#define TEST_VFORK_ENABLED 0
+#define TEST_VFORK_ENABLED 1
 #endif
 
 /// 



CVS commit: src/tests/lib/libc/sys

2019-06-13 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Jun 13 20:26:06 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Enable vfork(2) ATF tests in t_ptrace_wait*

The racing issues are gone in my local setup.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 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.



CVS commit: src/tests/lib/libc/sys

2019-06-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun 12 17:07:11 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new ATF ptrace(2) tests for posix_spawn, reusing tests for fork/vfork

New tests:
 - posix_spawn_detach_spawner
 - posix_spawn_kill_spawner
 - posix_spawn_singalmasked
 - posix_spawn_singalignored

All test pass.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.125 src/tests/lib/libc/sys/t_ptrace_wait.c:1.126
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.125	Tue Jun 11 23:30:05 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Wed Jun 12 17:07:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.125 2019/06/11 23:30:05 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.126 2019/06/12 17:07:11 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.125 2019/06/11 23:30:05 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.126 2019/06/12 17:07:11 kamil Exp $");
 
 #include 
 #include 
@@ -3195,7 +3195,7 @@ ATF_TC_HEAD(name, tc)			\
 {	\
 	atf_tc_set_md_var(tc, "descr", "Verify " fun "() "		\
 	"called with 0%s%s%s%s in EVENT_MASK",			\
-	tspawn ? "|PTRACE_FORK" : "",\
+	tspawn ? "|PTRACE_POSIX_SPAWN" : "",			\
 	tfork ? "|PTRACE_FORK" : "",\
 	tvfork ? "|PTRACE_VFORK" : "",\
 	tvforkdone ? "|PTRACE_VFORK_DONE" : "");			\
@@ -3282,11 +3282,10 @@ FORK_TEST(posix_spawn16, "spawn", true, 
 
 #if defined(TWAIT_HAVE_PID)
 static void
-fork_detach_forker_body(bool detachfork, bool detachvfork,
-bool detachvforkdone, bool kill_process)
+fork_detach_forker_body(const char *fn, bool kill_process)
 {
 	const int exitval = 5;
-	const int exitval2 = 15;
+	const int exitval2 = 0; /* Matches exit value from /bin/echo */
 	const int sigval = SIGSTOP;
 	pid_t child, child2 = 0, wpid;
 #if defined(TWAIT_HAVE_STATUS)
@@ -3297,17 +3296,9 @@ fork_detach_forker_body(bool detachfork,
 	ptrace_event_t event;
 	const int elen = sizeof(event);
 
-	pid_t (*fn)(void);
 	int op;
 
-	ATF_REQUIRE((detachfork && !detachvfork && !detachvforkdone) ||
-	(!detachfork && detachvfork && !detachvforkdone) ||
-	(!detachfork && !detachvfork && detachvforkdone));
-
-	if (detachfork)
-		fn = fork;
-	else
-		fn = vfork;
+	char * const arg[] = { __UNCONST("/bin/echo"), NULL };
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
@@ -3318,10 +3309,19 @@ fork_detach_forker_body(bool detachfork,
 		DPRINTF("Before raising %s from child\n", strsignal(sigval));
 		FORKEE_ASSERT(raise(sigval) == 0);
 
-		FORKEE_ASSERT((child2 = (fn)()) != -1);
+		if (strcmp(fn, "spawn") == 0) {
+			FORKEE_ASSERT_EQ(posix_spawn(,
+			arg[0], NULL, NULL, arg, NULL), 0);
+		} else  {
+			if (strcmp(fn, "fork") == 0) {
+FORKEE_ASSERT((child2 = fork()) != -1);
+			} else {
+FORKEE_ASSERT((child2 = vfork()) != -1);
+			}
 
-		if (child2 == 0)
-			_exit(exitval2);
+			if (child2 == 0)
+_exit(exitval2);
+		}
 
 		FORKEE_REQUIRE_SUCCESS
 		(wpid = TWAIT_GENERIC(child2, , 0), child2);
@@ -3339,7 +3339,8 @@ fork_detach_forker_body(bool detachfork,
 	validate_status_stopped(status, sigval);
 
 	DPRINTF("Set EVENT_MASK for the child %d\n", child);
-	event.pe_set_event = PTRACE_FORK | PTRACE_VFORK | PTRACE_VFORK_DONE;
+	event.pe_set_event = PTRACE_POSIX_SPAWN | PTRACE_FORK | PTRACE_VFORK
+		| PTRACE_VFORK_DONE;
 	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
 
 	DPRINTF("Before resuming the child process where it left off and "
@@ -3353,13 +3354,21 @@ fork_detach_forker_body(bool detachfork,
 
 	SYSCALL_REQUIRE(
 	ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
-	op = (fn == fork) ? PTRACE_FORK : PTRACE_VFORK;
+
+	if (strcmp(fn, "spawn") == 0)
+		op = PTRACE_POSIX_SPAWN;
+	else if (strcmp(fn, "fork") == 0)
+		op = PTRACE_FORK;
+	else
+		op = PTRACE_VFORK;
+
 	ATF_REQUIRE_EQ(state.pe_report_event & op, op);
 
 	child2 = state.pe_other_pid;
 	DPRINTF("Reported ptrace event with forkee %d\n", child2);
 
-	if (detachfork || detachvfork)
+	if (strcmp(fn, "spawn") == 0 || strcmp(fn, "fork") == 0 ||
+	strcmp(fn, "vfork") == 0)
 		op = kill_process ? PT_KILL : PT_DETACH;
 	else
 		op = PT_CONTINUE;
@@ -3373,7 +3382,13 @@ fork_detach_forker_body(bool detachfork,
 
 	SYSCALL_REQUIRE(
 	ptrace(PT_GET_PROCESS_STATE, child2, , slen) != -1);
-	op = (fn == fork) ? PTRACE_FORK : PTRACE_VFORK;
+	if (strcmp(fn, "spawn") == 0)
+		op = PTRACE_POSIX_SPAWN;
+	else if (strcmp(fn, "fork") == 0)
+		op = PTRACE_FORK;
+	else
+		op = PTRACE_VFORK;
+	
 	ATF_REQUIRE_EQ(state.pe_report_event 

CVS commit: src/tests/lib/libc/sys

2019-06-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun 12 17:07:11 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new ATF ptrace(2) tests for posix_spawn, reusing tests for fork/vfork

New tests:
 - posix_spawn_detach_spawner
 - posix_spawn_kill_spawner
 - posix_spawn_singalmasked
 - posix_spawn_singalignored

All test pass.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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.



CVS commit: src/tests/lib/libc/sys

2019-06-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun 11 23:30:05 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new PTRACE_POSIX_SPAWN tests in ptrace(3)

Add test:
 - eventmask_preserved_posix_spawn
 - fork9..fork16
 - vfork9..vfork16
 - posix_spawn1..16

New tests verify semantics of PTRACE_POSIX_SPAWN.

All tests pass.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.124 src/tests/lib/libc/sys/t_ptrace_wait.c:1.125
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.124	Mon Jun 10 22:16:06 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue Jun 11 23:30:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.124 2019/06/10 22:16:06 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.125 2019/06/11 23:30:05 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.124 2019/06/10 22:16:06 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.125 2019/06/11 23:30:05 kamil Exp $");
 
 #include 
 #include 
@@ -2947,6 +2947,8 @@ eventmask_preserved(int event)
 	ptrace(PT_SET_EVENT_MASK, child, _event, len) != -1);
 	SYSCALL_REQUIRE(
 	ptrace(PT_GET_EVENT_MASK, child, _event, len) != -1);
+	DPRINTF("set_event=%#x get_event=%#x\n", set_event.pe_set_event,
+	get_event.pe_set_event);
 	ATF_REQUIRE(memcmp(_event, _event, len) == 0);
 
 	DPRINTF("Before resuming the child process where it left off and "
@@ -2982,15 +2984,16 @@ EVENTMASK_PRESERVED(eventmask_preserved_
 EVENTMASK_PRESERVED(eventmask_preserved_vfork_done, PTRACE_VFORK_DONE)
 EVENTMASK_PRESERVED(eventmask_preserved_lwp_create, PTRACE_LWP_CREATE)
 EVENTMASK_PRESERVED(eventmask_preserved_lwp_exit, PTRACE_LWP_EXIT)
+EVENTMASK_PRESERVED(eventmask_preserved_posix_spawn, PTRACE_POSIX_SPAWN)
 
 /// 
 
 static void
-fork_body(pid_t (*fn)(void), bool spawn, bool trackfork, bool trackvfork,
+fork_body(const char *fn, bool trackspawn, bool trackfork, bool trackvfork,
 bool trackvforkdone)
 {
 	const int exitval = 5;
-	const int exitval2 = 15;
+	const int exitval2 = 0; /* This matched exit status from /bin/echo */
 	const int sigval = SIGSTOP;
 	pid_t child, child2 = 0, wpid;
 #if defined(TWAIT_HAVE_STATUS)
@@ -3003,9 +3006,6 @@ fork_body(pid_t (*fn)(void), bool spawn,
 
 	char * const arg[] = { __UNCONST("/bin/echo"), NULL };
 
-	if (spawn)
-		atf_tc_skip("posix_spawn() is not supported");
-
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3015,11 +3015,15 @@ fork_body(pid_t (*fn)(void), bool spawn,
 		DPRINTF("Before raising %s from child\n", strsignal(sigval));
 		FORKEE_ASSERT(raise(sigval) == 0);
 
-		if (spawn) {
+		if (strcmp(fn, "spawn") == 0) {
 			FORKEE_ASSERT_EQ(posix_spawn(,
 			arg[0], NULL, NULL, arg, NULL), 0);
-		} else if (fn == fork || fn == vfork) {
-			FORKEE_ASSERT((child2 = (fn)()) != -1);
+		} else {
+			if (strcmp(fn, "fork") == 0) {
+FORKEE_ASSERT((child2 = fork()) != -1);
+			} else if (strcmp(fn, "vfork") == 0) {
+FORKEE_ASSERT((child2 = vfork()) != -1);
+			}
 
 			if (child2 == 0)
 _exit(exitval2);
@@ -3039,11 +3043,14 @@ fork_body(pid_t (*fn)(void), bool spawn,
 
 	validate_status_stopped(status, sigval);
 
-	DPRINTF("Set 0%s%s%s in EVENT_MASK for the child %d\n",
+	DPRINTF("Set 0%s%s%s%s in EVENT_MASK for the child %d\n",
+	trackspawn ? "|PTRACE_POSIX_SPAWN" : "",
 	trackfork ? "|PTRACE_FORK" : "",
 	trackvfork ? "|PTRACE_VFORK" : "",
 	trackvforkdone ? "|PTRACE_VFORK_DONE" : "", child);
 	event.pe_set_event = 0;
+	if (trackspawn)
+		event.pe_set_event |= PTRACE_POSIX_SPAWN;
 	if (trackfork)
 		event.pe_set_event |= PTRACE_FORK;
 	if (trackvfork)
@@ -3057,7 +3064,9 @@ fork_body(pid_t (*fn)(void), bool spawn,
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 
 #if defined(TWAIT_HAVE_PID)
-	if ((trackfork && fn == fork) || (trackvfork && fn == vfork)) {
+	if ((trackspawn && strcmp(fn, "spawn") == 0) ||
+	(trackfork && strcmp(fn, "fork") == 0) ||
+	(trackvfork && strcmp(fn, "vfork") == 0)) {
 		DPRINTF("Before calling %s() for the child %d\n", TWAIT_FNAME,
 		child);
 		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0),
@@ -3067,11 +3076,16 @@ fork_body(pid_t (*fn)(void), bool spawn,
 
 		SYSCALL_REQUIRE(
 		ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
-		if (trackfork && fn == fork) {
+		if (trackspawn && strcmp(fn, "spawn") == 0) {
+			ATF_REQUIRE_EQ(
+			state.pe_report_event & PTRACE_POSIX_SPAWN,
+			   PTRACE_POSIX_SPAWN);
+		}
+		if (trackfork && 

CVS commit: src/tests/lib/libc/sys

2019-06-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun 11 23:30:05 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new PTRACE_POSIX_SPAWN tests in ptrace(3)

Add test:
 - eventmask_preserved_posix_spawn
 - fork9..fork16
 - vfork9..vfork16
 - posix_spawn1..16

New tests verify semantics of PTRACE_POSIX_SPAWN.

All tests pass.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 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.



CVS commit: src/tests/lib/libc/sys

2019-06-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 10 22:16:06 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add posix_spawn(3) ATF tests in t_ptrace_wait*

New tests verify whether forking process reports forking events to a
debugger.

Right now there is no support in the kernel for this system.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 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.



CVS commit: src/tests/lib/libc/sys

2019-06-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 10 22:16:06 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add posix_spawn(3) ATF tests in t_ptrace_wait*

New tests verify whether forking process reports forking events to a
debugger.

Right now there is no support in the kernel for this system.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.123 src/tests/lib/libc/sys/t_ptrace_wait.c:1.124
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.123	Mon Jun 10 21:18:04 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon Jun 10 22:16:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.123 2019/06/10 21:18:04 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.124 2019/06/10 22:16:06 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.123 2019/06/10 21:18:04 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.124 2019/06/10 22:16:06 kamil Exp $");
 
 #include 
 #include 
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.12
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2985,7 +2986,7 @@ EVENTMASK_PRESERVED(eventmask_preserved_
 /// 
 
 static void
-fork_body(pid_t (*fn)(void), bool trackfork, bool trackvfork,
+fork_body(pid_t (*fn)(void), bool spawn, bool trackfork, bool trackvfork,
 bool trackvforkdone)
 {
 	const int exitval = 5;
@@ -3000,6 +3001,11 @@ fork_body(pid_t (*fn)(void), bool trackf
 	ptrace_event_t event;
 	const int elen = sizeof(event);
 
+	char * const arg[] = { __UNCONST("/bin/echo"), NULL };
+
+	if (spawn)
+		atf_tc_skip("posix_spawn() is not supported");
+
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3009,11 +3015,15 @@ fork_body(pid_t (*fn)(void), bool trackf
 		DPRINTF("Before raising %s from child\n", strsignal(sigval));
 		FORKEE_ASSERT(raise(sigval) == 0);
 
-		FORKEE_ASSERT((child2 = (fn)()) != -1);
-
-		if (child2 == 0)
-			_exit(exitval2);
+		if (spawn) {
+			FORKEE_ASSERT_EQ(posix_spawn(,
+			arg[0], NULL, NULL, arg, NULL), 0);
+		} else if (fn == fork || fn == vfork) {
+			FORKEE_ASSERT((child2 = (fn)()) != -1);
 
+			if (child2 == 0)
+_exit(exitval2);
+		}
 		FORKEE_REQUIRE_SUCCESS
 		(wpid = TWAIT_GENERIC(child2, , 0), child2);
 
@@ -3158,7 +3168,7 @@ fork_body(pid_t (*fn)(void), bool trackf
 	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
 }
 
-#define FORK_TEST(name,fun,tfork,tvfork,tvforkdone)			\
+#define FORK_TEST(name,fun,spawn,tfork,tvfork,tvforkdone)		\
 ATF_TC(name);\
 ATF_TC_HEAD(name, tc)			\
 {	\
@@ -3172,37 +3182,51 @@ ATF_TC_HEAD(name, tc)			\
 ATF_TC_BODY(name, tc)			\
 {	\
 	\
-	fork_body(fun, tfork, tvfork, tvforkdone);			\
+	fork_body(fun, spawn, tfork, tvfork, tvforkdone);		\
 }
 
-FORK_TEST(fork1, fork, false, false, false)
+FORK_TEST(fork1, fork, false, false, false, false)
 #if defined(TWAIT_HAVE_PID)
-FORK_TEST(fork2, fork, true, false, false)
-FORK_TEST(fork3, fork, false, true, false)
-FORK_TEST(fork4, fork, true, true, false)
+FORK_TEST(fork2, fork, false, true, false, false)
+FORK_TEST(fork3, fork, false, false, true, false)
+FORK_TEST(fork4, fork, false, true, true, false)
 #endif
-FORK_TEST(fork5, fork, false, false, true)
+FORK_TEST(fork5, fork, false, false, false, true)
 #if defined(TWAIT_HAVE_PID)
-FORK_TEST(fork6, fork, true, false, true)
-FORK_TEST(fork7, fork, false, true, true)
-FORK_TEST(fork8, fork, true, true, true)
+FORK_TEST(fork6, fork, false, true, false, true)
+FORK_TEST(fork7, fork, false, false, true, true)
+FORK_TEST(fork8, fork, false, true, true, true)
 #endif
 
 #if TEST_VFORK_ENABLED
-FORK_TEST(vfork1, vfork, false, false, false)
+FORK_TEST(vfork1, vfork, false, false, false, false)
 #if defined(TWAIT_HAVE_PID)
-FORK_TEST(vfork2, vfork, true, false, false)
-FORK_TEST(vfork3, vfork, false, true, false)
-FORK_TEST(vfork4, vfork, true, true, false)
+FORK_TEST(vfork2, vfork, false, true, false, false)
+FORK_TEST(vfork3, vfork, false, false, true, false)
+FORK_TEST(vfork4, vfork, false, true, true, false)
 #endif
-FORK_TEST(vfork5, vfork, false, false, true)
+FORK_TEST(vfork5, vfork, false, false, false, true)
 #if defined(TWAIT_HAVE_PID)
-FORK_TEST(vfork6, vfork, true, false, true)
-FORK_TEST(vfork7, vfork, false, true, true)
-FORK_TEST(vfork8, vfork, true, true, true)
+FORK_TEST(vfork6, vfork, false, true, false, true)
+FORK_TEST(vfork7, vfork, false, false, true, true)
+FORK_TEST(vfork8, vfork, false, true, true, true)
 

CVS commit: src/tests/lib/libc/sys

2019-06-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 10 21:18:04 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add more verbosity to debug messages in t_ptrace_wait

Log func() file:line for each debug message.

Most messages are similar one with the other and this change allows easier
navigation in the code.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.122 src/tests/lib/libc/sys/t_ptrace_wait.c:1.123
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.122	Sat May 25 03:25:08 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon Jun 10 21:18:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.122 2019/05/25 03:25:08 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.123 2019/06/10 21:18:04 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.122 2019/05/25 03:25:08 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.123 2019/06/10 21:18:04 kamil Exp $");
 
 #include 
 #include 
@@ -94,7 +94,8 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.12
 static int debug = 0;
 
 #define DPRINTF(a, ...)	do  \
-	if (debug) printf(a,  ##__VA_ARGS__); \
+	if (debug) \
+	printf("%s() %s:%d " a, __func__, __FILE__, __LINE__,  ##__VA_ARGS__); \
 while (/*CONSTCOND*/0)
 
 #ifndef TEST_VFORK_ENABLED



CVS commit: src/tests/lib/libc/sys

2019-06-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 10 21:18:04 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add more verbosity to debug messages in t_ptrace_wait

Log func() file:line for each debug message.

Most messages are similar one with the other and this change allows easier
navigation in the code.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 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.



CVS commit: src/tests/lib/libc/sys

2019-06-04 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Tue Jun  4 12:17:42 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Fix alignment of SSE filling data


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libc/sys

2019-06-04 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Tue Jun  4 12:17:42 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Fix alignment of SSE filling data


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.14 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.15
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.14	Tue Jun  4 12:17:05 2019
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Tue Jun  4 12:17:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.14 2019/06/04 12:17:05 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.15 2019/06/04 12:17:42 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -2600,7 +2600,7 @@ static __inline void get_xmm_regs(void* 
 {
 	const struct {
 		uint64_t a, b;
-	} fill = {0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F};
+	} fill __aligned(16) = {0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F};
 
 	__asm__ __volatile__(
 		/* fill registers with clobber pattern */



CVS commit: src/tests/lib/libc/sys

2019-06-04 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Tue Jun  4 12:17:05 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_amd64_wait.h t_ptrace_i386_wait.h
t_ptrace_x86_wait.h

Log Message:
Add more debug to register writing tests


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/sys/t_ptrace_amd64_wait.h
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/sys/t_ptrace_i386_wait.h
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_amd64_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_amd64_wait.h:1.10 src/tests/lib/libc/sys/t_ptrace_amd64_wait.h:1.11
--- src/tests/lib/libc/sys/t_ptrace_amd64_wait.h:1.10	Fri May 10 16:24:35 2019
+++ src/tests/lib/libc/sys/t_ptrace_amd64_wait.h	Tue Jun  4 12:17:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_amd64_wait.h,v 1.10 2019/05/10 16:24:35 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_amd64_wait.h,v 1.11 2019/06/04 12:17:05 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -262,6 +262,7 @@ ATF_TC_BODY(x86_64_regs_gp_write, tc)
 			:
 		);
 
+		DPRINTF("Before comparing results\n");
 		FORKEE_ASSERT_EQ(v_rax, rax);
 		FORKEE_ASSERT_EQ(v_rbx, rbx);
 		FORKEE_ASSERT_EQ(v_rcx, rcx);
@@ -462,6 +463,7 @@ ATF_TC_BODY(x86_64_regs_r8_write, tc)
 			: "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
 		);
 
+		DPRINTF("Before comparing results\n");
 		FORKEE_ASSERT_EQ(v_r8[0], r8[0]);
 		FORKEE_ASSERT_EQ(v_r8[1], r8[1]);
 		FORKEE_ASSERT_EQ(v_r8[2], r8[2]);

Index: src/tests/lib/libc/sys/t_ptrace_i386_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_i386_wait.h:1.8 src/tests/lib/libc/sys/t_ptrace_i386_wait.h:1.9
--- src/tests/lib/libc/sys/t_ptrace_i386_wait.h:1.8	Fri May 10 16:24:35 2019
+++ src/tests/lib/libc/sys/t_ptrace_i386_wait.h	Tue Jun  4 12:17:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_i386_wait.h,v 1.8 2019/05/10 16:24:35 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_i386_wait.h,v 1.9 2019/06/04 12:17:05 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -226,6 +226,7 @@ ATF_TC_BODY(i386_regs_gp_write, tc)
 			:
 		);
 
+		DPRINTF("Before comparing results\n");
 		FORKEE_ASSERT_EQ(v_eax, eax);
 		FORKEE_ASSERT_EQ(v_ebx, ebx);
 		FORKEE_ASSERT_EQ(v_ecx, ecx);
@@ -393,6 +394,7 @@ ATF_TC_BODY(i386_regs_ebp_esp_write, tc)
 			:
 		);
 
+		DPRINTF("Before comparing results\n");
 		FORKEE_ASSERT_EQ(v_esp, esp);
 		FORKEE_ASSERT_EQ(v_ebp, ebp);
 

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.13 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.14
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.13	Fri May 10 18:07:10 2019
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Tue Jun  4 12:17:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.13 2019/05/10 18:07:10 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.14 2019/06/04 12:17:05 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -2387,6 +2387,7 @@ ATF_TC_BODY(x86_regs_mm_write, tc)
 		DPRINTF("Before running assembly from child\n");
 		get_mm_regs(v_mm);
 
+		DPRINTF("Before comparing results\n");
 		FORKEE_ASSERT_EQ(v_mm[0], mm[0]);
 		FORKEE_ASSERT_EQ(v_mm[1], mm[1]);
 		FORKEE_ASSERT_EQ(v_mm[2], mm[2]);
@@ -2724,6 +2725,7 @@ ATF_TC_BODY(x86_regs_xmm_write, tc)
 		DPRINTF("Before running assembly from child\n");
 		get_xmm_regs(v_xmm);
 
+		DPRINTF("Before comparing results\n");
 		FORKEE_ASSERT(!memcmp(_xmm[0], [0], sizeof(*xmm)));
 		FORKEE_ASSERT(!memcmp(_xmm[1], [1], sizeof(*xmm)));
 		FORKEE_ASSERT(!memcmp(_xmm[2], [2], sizeof(*xmm)));



CVS commit: src/tests/lib/libc/sys

2019-06-04 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Tue Jun  4 12:17:05 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_amd64_wait.h t_ptrace_i386_wait.h
t_ptrace_x86_wait.h

Log Message:
Add more debug to register writing tests


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/sys/t_ptrace_amd64_wait.h
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/sys/t_ptrace_i386_wait.h
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libc/sys

2019-05-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 25 03:25:08 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new user_va0_disable* tests in t_ptrace_wait*

Add tests:
 - user_va0_disable_pt_continue
 - user_va0_disable_pt_syscall
 - user_va0_disable_pt_detach

Assert that setting PC to 0x0 in PT_CONTINUE/PT_SYSCALL/PT_DETACH for
vm.user_va0_disable==0 is disallowed.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 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.



CVS commit: src/tests/lib/libc/sys

2019-05-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 25 03:25:08 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Add new user_va0_disable* tests in t_ptrace_wait*

Add tests:
 - user_va0_disable_pt_continue
 - user_va0_disable_pt_syscall
 - user_va0_disable_pt_detach

Assert that setting PC to 0x0 in PT_CONTINUE/PT_SYSCALL/PT_DETACH for
vm.user_va0_disable==0 is disallowed.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 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.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.121 src/tests/lib/libc/sys/t_ptrace_wait.c:1.122
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.121	Thu May  9 13:07:35 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sat May 25 03:25:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.121 2019/05/09 13:07:35 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.122 2019/05/25 03:25:08 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.121 2019/05/09 13:07:35 mgorny Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.122 2019/05/25 03:25:08 kamil Exp $");
 
 #include 
 #include 
@@ -7438,6 +7438,94 @@ TRACEME_VFORK_CLONE_TEST(traceme_vfork_c
 
 /// 
 
+static void
+user_va0_disable(int operation)
+{
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	const int sigval = SIGSTOP;
+	int rv;
+
+	struct ptrace_siginfo info;
+
+	if (get_user_va0_disable() == 0)
+		atf_tc_skip("vm.user_va0_disable is set to 0");
+
+	memset(, 0, sizeof(info));
+
+	DPRINTF("Before forking process PID=%d\n", getpid());
+	SYSCALL_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		DPRINTF("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		/* NOTREACHED */
+		FORKEE_ASSERTX(0 && "This shall not be reached");
+		__unreachable();
+	}
+	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
+		"child\n");
+	SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, ,
+		sizeof(info)) != -1);
+
+	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
+	DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
+		"si_errno=%#x\n",
+		info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+		info.psi_siginfo.si_errno);
+
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
+	DPRINTF("Before resuming the child process in PC=0x0 "
+	"and without signal to be sent\n");
+	errno = 0;
+	rv = ptrace(operation, child, (void *)0, 0);
+	ATF_REQUIRE_EQ(errno, EINVAL);
+	ATF_REQUIRE_EQ(rv, -1);
+
+	SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
+
+	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+	validate_status_signaled(status, SIGKILL, 0);
+
+	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
+}
+
+#define USER_VA0_DISABLE(test, operation)\
+ATF_TC(test);\
+ATF_TC_HEAD(test, tc)			\
+{	\
+	atf_tc_set_md_var(tc, "descr",	\
+	"Verify behavior of " #operation " with PC set to 0x0");	\
+}	\
+	\
+ATF_TC_BODY(test, tc)			\
+{	\
+	\
+	user_va0_disable(operation);	\
+}
+
+USER_VA0_DISABLE(user_va0_disable_pt_continue, PT_CONTINUE)
+USER_VA0_DISABLE(user_va0_disable_pt_syscall, PT_SYSCALL)
+USER_VA0_DISABLE(user_va0_disable_pt_detach, PT_DETACH)
+
+/// 
+
 #include "t_ptrace_amd64_wait.h"
 #include "t_ptrace_i386_wait.h"
 #include "t_ptrace_x86_wait.h"
@@ -7886,6 +7974,10 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC_HAVE_PID(tp, traceme_vfork_clone_vfork);
 #endif
 
+	ATF_TP_ADD_TC(tp, user_va0_disable_pt_continue);
+	ATF_TP_ADD_TC(tp, user_va0_disable_pt_syscall);
+	ATF_TP_ADD_TC(tp, user_va0_disable_pt_detach);
+
 	ATF_TP_ADD_TCS_PTRACE_WAIT_AMD64();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_I386();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_X86();



CVS commit: src/tests/lib/libc/sys

2019-05-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 25 03:22:53 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Add get_user_va0_disable() in t_ptrace_wait.h

Add a utility function to check vm.user_va0_disable.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libc/sys/t_ptrace_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libc/sys

2019-05-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 25 03:22:53 UTC 2019

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Add get_user_va0_disable() in t_ptrace_wait.h

Add a utility function to check vm.user_va0_disable.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libc/sys/t_ptrace_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.16 src/tests/lib/libc/sys/t_ptrace_wait.h:1.17
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.16	Thu Apr 25 19:15:23 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Sat May 25 03:22:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.16 2019/04/25 19:15:23 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.17 2019/05/25 03:22:53 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -553,6 +553,26 @@ can_we_set_dbregs(void)
 #endif
 
 static bool __used
+get_user_va0_disable(void)
+{
+	static int user_va0_disable = -1;
+	size_t user_va0_disable_len = sizeof(user_va0_disable);
+
+	if (user_va0_disable == -1) {
+		if (sysctlbyname("vm.user_va0_disable",
+			_va0_disable, _va0_disable_len, NULL, 0)
+			== -1) {
+			return true;
+		}
+	}
+
+	if (user_va0_disable > 0)
+		return true;
+	else
+		return false;
+}
+
+static bool __used
 can_we_write_to_text(pid_t pid)
 {
 	int mib[3];



Re: CVS commit: src/tests/lib/libc/sys

2018-05-25 Thread Jason Thorpe


> On May 24, 2018, at 10:45 PM, Kamil Rytarowski  wrote:
> 
> Fixed!

Confirmed!  Thanks!

-- thorpej



Re: CVS commit: src/tests/lib/libc/sys

2018-05-24 Thread Kamil Rytarowski
On 24.05.2018 06:17, Jason Thorpe wrote:
> This change seems to have broken building on 32-bit platforms (certainly at 
> least for 32-bit ARM):
> 
> #   compile  sys/t_ptrace_wait.o
> /nbsd/tools/bin/armv6--netbsdelf-eabihf-gcc -O2   -std=gnu99-Wall 
> -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-sign-compare  
> -Wsystem-headers   -Wno-traditional   -Wa,--fatal-warnings  -Wreturn-type 
> -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter 
> -Wno-sign-compare -Wsign-compare -Wformat=2  -Wno-format-zero-length  -Werror 
> -Wno-missing-noreturn   -fPIE--sysroot=/nbsd/destdir/rpi 
> -I/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/../../..  -c   
> -D_KERNTYPES 
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.c
> In file included from 
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.c:59:0:
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h: In 
> function 'trigger_bus':
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:561:20: 
> error: cast from pointer to integer of different size 
> [-Werror=pointer-to-int-cast]
>   FORKEE_ASSERT_NEQ((uintmax_t)fp, (uintmax_t)NULL);
> ^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:158:18: 
> note: in definition of macro 'FORKEE_ASSERT_NEQ'
>   uintmax_t vx = (x);  \
>   ^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:561:35: 
> error: cast from pointer to integer of different size 
> [-Werror=pointer-to-int-cast]
>   FORKEE_ASSERT_NEQ((uintmax_t)fp, (uintmax_t)NULL);
>^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:159:18: 
> note: in definition of macro 'FORKEE_ASSERT_NEQ'
>   uintmax_t vy = (y);  \
>   ^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:565:20: 
> error: cast from pointer to integer of different size 
> [-Werror=pointer-to-int-cast]
>   FORKEE_ASSERT_NEQ((uintmax_t)p, (uintmax_t)MAP_FAILED);
> ^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:158:18: 
> note: in definition of macro 'FORKEE_ASSERT_NEQ'
>   uintmax_t vx = (x);  \
>   ^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:565:34: 
> error: cast from pointer to integer of different size 
> [-Werror=pointer-to-int-cast]
>   FORKEE_ASSERT_NEQ((uintmax_t)p, (uintmax_t)MAP_FAILED);
>   ^
> /Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:159:18: 
> note: in definition of macro 'FORKEE_ASSERT_NEQ'
>   uintmax_t vy = (y);  \
>   ^
> cc1: all warnings being treated as errors
> 
> *** Failed target:  t_ptrace_wait.o
> 
> 
> Maybe uintptr_t is a better type to cast to?
> 
> 
>> On May 23, 2018, at 6:18 AM, Kamil Rytarowski  wrote:
>>
>> Module Name: src
>> Committed By:kamil
>> Date:Wed May 23 13:18:09 UTC 2018
>>
>> Modified Files:
>>  src/tests/lib/libc/sys: t_ptrace_wait.h
>>
>> Log Message:
>> 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 
>>
>>
>> To generate a diff of this commit:
>> cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_ptrace_wait.h
>>
>> Please note that diffs are not public domain; they are subject to the
>> copyright notices on the relevant files.
>>
> 
> -- thorpej
> 

Fixed!



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src/tests/lib/libc/sys

2018-05-23 Thread Jason Thorpe
This change seems to have broken building on 32-bit platforms (certainly at 
least for 32-bit ARM):

#   compile  sys/t_ptrace_wait.o
/nbsd/tools/bin/armv6--netbsdelf-eabihf-gcc -O2   -std=gnu99-Wall 
-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-sign-compare  
-Wsystem-headers   -Wno-traditional   -Wa,--fatal-warnings  -Wreturn-type 
-Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter 
-Wno-sign-compare -Wsign-compare -Wformat=2  -Wno-format-zero-length  -Werror 
-Wno-missing-noreturn   -fPIE--sysroot=/nbsd/destdir/rpi 
-I/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/../../..  -c   
-D_KERNTYPES 
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.c
In file included from 
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.c:59:0:
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h: In 
function 'trigger_bus':
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:561:20: 
error: cast from pointer to integer of different size 
[-Werror=pointer-to-int-cast]
  FORKEE_ASSERT_NEQ((uintmax_t)fp, (uintmax_t)NULL);
^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:158:18: 
note: in definition of macro 'FORKEE_ASSERT_NEQ'
  uintmax_t vx = (x);  \
  ^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:561:35: 
error: cast from pointer to integer of different size 
[-Werror=pointer-to-int-cast]
  FORKEE_ASSERT_NEQ((uintmax_t)fp, (uintmax_t)NULL);
   ^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:159:18: 
note: in definition of macro 'FORKEE_ASSERT_NEQ'
  uintmax_t vy = (y);  \
  ^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:565:20: 
error: cast from pointer to integer of different size 
[-Werror=pointer-to-int-cast]
  FORKEE_ASSERT_NEQ((uintmax_t)p, (uintmax_t)MAP_FAILED);
^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:158:18: 
note: in definition of macro 'FORKEE_ASSERT_NEQ'
  uintmax_t vx = (x);  \
  ^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:565:34: 
error: cast from pointer to integer of different size 
[-Werror=pointer-to-int-cast]
  FORKEE_ASSERT_NEQ((uintmax_t)p, (uintmax_t)MAP_FAILED);
  ^
/Users/thorpej/NetBSD/current/src/tests/lib/libc/sys/t_ptrace_wait.h:159:18: 
note: in definition of macro 'FORKEE_ASSERT_NEQ'
  uintmax_t vy = (y);  \
  ^
cc1: all warnings being treated as errors

*** Failed target:  t_ptrace_wait.o


Maybe uintptr_t is a better type to cast to?


> On May 23, 2018, at 6:18 AM, Kamil Rytarowski  wrote:
> 
> Module Name:  src
> Committed By: kamil
> Date: Wed May 23 13:18:09 UTC 2018
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ptrace_wait.h
> 
> Log Message:
> 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 
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_ptrace_wait.h
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 

-- thorpej



Re: CVS commit: src/tests/lib/libc/sys

2018-02-27 Thread Valery Ushakov
On Tue, Feb 27, 2018 at 11:15:53 +, Kamil Rytarowski wrote:

> Module Name:  src
> Committed By: kamil
> Date: Tue Feb 27 11:15:53 UTC 2018
> 
> Modified Files:
>   src/tests/lib/libc/sys: t_ucontext.c
> 
> Log Message:
> Make the t_ucontext.c test more portable
> 
> Cast _UC_MACHINE_*() to (register_t).
> This allows to print the returned values with PRIxREGISTER.
> 
> This corrects build failures on MIPS and HPPA.
> sizeof(int) == sizeof(long) on these 32-bit systems.

Why does this code use  instead of ?

Note, that PRIxREGISTER and other kernel PRIx* macros are, for better
or worse, not coming from inttypes headers, but from
.  But they can be deined in terms of standard PRIx*
macros and for the userland code those are officially defined by
.

-uwe


Re: CVS commit: src/tests/lib/libc/sys

2017-05-23 Thread Alexander Mihalicyn
help

On Tue, May 23, 2017 at 7:01 PM, Christos Zoulas 
wrote:

> Module Name:src
> Committed By:   christos
> Date:   Tue May 23 16:01:46 UTC 2017
>
> Modified Files:
> src/tests/lib/libc/sys: t_mincore.c
>
> Log Message:
> Add the error in syscall failure.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/sys/t_mincore.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>
>


Re: CVS commit: src/tests/lib/libc/sys

2017-03-24 Thread Paul Goyette

Module Name:src
Committed By:   martin
Date:   Fri Mar 24 08:18:27 UTC 2017

Modified Files:
src/tests/lib/libc/sys: t_mprotect.c

Log Message:
Do not toggle global security.pax.mprotect state in an attempt to
activate it for the current process. It does not work and tests should
not change global system state anyway.
Instead: skip the test is pax.mprotect is not globally enabled. We
could use a better check for this (querying the current processes pax 
flags), but unfortunately we don't have one.


I'll be committing a new sysctl variable proc.curproc.paxflags which 
will provide the ability to quest the current process's pax flags (or, 
indeed, the pax flags for any process which the caller is "allowed to 
see").



+--+--++
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:  |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+--+--++


Re: CVS commit: src/tests/lib/libc/sys

2017-01-13 Thread Paul Goyette

Should address PR bin/51869

On Sat, 14 Jan 2017, Paul Goyette wrote:


Module Name:src
Committed By:   pgoyette
Date:   Sat Jan 14 03:59:58 UTC 2017

Modified Files:
src/tests/lib/libc/sys: Makefile

Log Message:
Set FILESBUILD=yes to actually run the creation script for the file.

Should fix the build by creating a file which install can then find.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libc/sys/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.


!DSPAM:5879a267143851834045299!




+--+--++
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:  |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+--+--++


Re: CVS commit: src/tests/lib/libc/sys

2016-08-09 Thread Robert Elz
Date:Tue, 9 Aug 2016 12:02:44 +
From:"Robert Elz" 
Message-ID:  <20160809120244.9f9d0f...@cvs.netbsd.org>

Ignore this part ...

  | Note that NetBSD mlock(2) talks about EINVAL for cases where the length
  | parameter is negative ... but that is a size_t - good luck having that
  | ever occur (the man page will soon be corrected as well.)

I was reading the man page on a NetBSD-7 system ... didn't notice that
the man page was already corrected in current until I went to fix it!

kre



Re: CVS commit: src/tests/lib/libc/sys

2013-03-09 Thread David Laight
On Sat, Mar 09, 2013 at 12:19:08AM +0100, Martin Husemann wrote:
 On Fri, Mar 08, 2013 at 11:03:23PM +, David Laight wrote:
  Should the 'no timeout' case (try to) check that the elapsed time is
  less than one tick?
 
 I gave the (partly virtual) test platforms a bit more slope and made it  1s
 instead of 1 tick, but otherwise: yes.

If the test did:
poll(0, 0, 1);
gettimeofday();
run_test();
gettimeofday();
It should be able to distinguish between the 'no sleep' and 'sleep
for one tick' cases.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/tests/lib/libc/sys

2013-03-08 Thread David Laight
On Fri, Mar 08, 2013 at 05:01:54PM +, Martin Husemann wrote:
 Module Name:  src
 Committed By: martin
 Date: Fri Mar  8 17:01:54 UTC 2013
 
 Modified Files:
   src/tests/lib/libc/sys: Makefile
 Added Files:
   src/tests/lib/libc/sys: t_sigtimedwait.c
 Removed Files:
   src/tests/lib/libc/sys: t_sigtimedwait_pr_47625.c
 
 Log Message:
 Rename testprogram and make it more general by adding other testcases.
 One commented out, I didn't manage to get all signal handling correct
 for now.

Should the 'no timeout' case (try to) check that the elapsed time is
less than one tick?

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/tests/lib/libc/sys

2013-03-08 Thread Martin Husemann
On Fri, Mar 08, 2013 at 11:03:23PM +, David Laight wrote:
 Should the 'no timeout' case (try to) check that the elapsed time is
 less than one tick?

I gave the (partly virtual) test platforms a bit more slope and made it  1s
instead of 1 tick, but otherwise: yes.

Martin


Re: CVS commit: src/tests/lib/libc/sys

2012-09-08 Thread Christos Zoulas
In article 20120908122506.92aa117...@cvs.netbsd.org,
Martin Husemann source-changes-d@NetBSD.org wrote:
Module Name:   src
Committed By:  martin
Date:  Sat Sep  8 12:25:06 UTC 2012

Modified Files:
   src/tests/lib/libc/sys: t_mlock.c

Log Message:
Make this compile on archs where VM_MIN_ADDRESS is not defined (or not
exported to userland)

Why not add a test for == VM_MIN_ADDRESS too?

christos



Re: CVS commit: src/tests/lib/libc/sys

2012-09-08 Thread Martin Husemann
On Sat, Sep 08, 2012 at 02:28:53PM +, Christos Zoulas wrote:
 Why not add a test for == VM_MIN_ADDRESS too?

If this is != NULL, we can not rely on it not to be mapped, so I don't
see any additional value in that case. The brk+1 page test should be good
enough.

Martin


Re: CVS commit: src/tests/lib/libc/sys

2012-09-08 Thread Christos Zoulas
On Sep 8,  4:32pm, mar...@duskware.de (Martin Husemann) wrote:
-- Subject: Re: CVS commit: src/tests/lib/libc/sys

| On Sat, Sep 08, 2012 at 02:28:53PM +, Christos Zoulas wrote:
|  Why not add a test for == VM_MIN_ADDRESS too?
| 
| If this is != NULL, we can not rely on it not to be mapped, so I don't
| see any additional value in that case. The brk+1 page test should be good
| enough.

Thanks for explaining.

christos