CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: riastradh Date: Tue Nov 28 00:27:05 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Fix format string for size_t. Tested this on i386 since that had been crashing before, but i386 doesn't see %zu for unsigned int as a problem. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libpthread/t_stack.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/libpthread
Module Name:src Committed By: riastradh Date: Tue Nov 28 00:27:05 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Fix format string for size_t. Tested this on i386 since that had been crashing before, but i386 doesn't see %zu for unsigned int as a problem. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libpthread/t_stack.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/libpthread/t_stack.c diff -u src/tests/lib/libpthread/t_stack.c:1.4 src/tests/lib/libpthread/t_stack.c:1.5 --- src/tests/lib/libpthread/t_stack.c:1.4 Mon Nov 27 22:18:29 2023 +++ src/tests/lib/libpthread/t_stack.c Tue Nov 28 00:27:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stack.c,v 1.4 2023/11/27 22:18:29 riastradh Exp $ */ +/* $NetBSD: t_stack.c,v 1.5 2023/11/28 00:27:05 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #define _KMEMUSER /* __MACHINE_STACK_GROWS_UP */ #include -__RCSID("$NetBSD: t_stack.c,v 1.4 2023/11/27 22:18:29 riastradh Exp $"); +__RCSID("$NetBSD: t_stack.c,v 1.5 2023/11/28 00:27:05 riastradh Exp $"); #include #include @@ -127,7 +127,7 @@ getdefaultguardsize(void) */ extern size_t pthread__guardsize; /* pthread_int.h */ ATF_CHECK_EQ_MSG(guardsize, pthread__guardsize, - "guardsize=%zu pthread__guardsize=%zu", + "guardsize=%u pthread__guardsize=%zu", guardsize, pthread__guardsize); return guardsize;
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: riastradh Date: Mon Nov 27 22:18:29 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Appease gcc12 maybe-uninitialized warning. The jmp_buf is not, in fact, uninitialized at the point of use, but it doesn't hurt to narrow the scope a bit to between when the jmp_buf is initialized by setjmp, and when the signal handler might be called after sigaction. Noted by prlw1. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_stack.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/libpthread
Module Name:src Committed By: riastradh Date: Mon Nov 27 22:18:29 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Appease gcc12 maybe-uninitialized warning. The jmp_buf is not, in fact, uninitialized at the point of use, but it doesn't hurt to narrow the scope a bit to between when the jmp_buf is initialized by setjmp, and when the signal handler might be called after sigaction. Noted by prlw1. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_stack.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/libpthread/t_stack.c diff -u src/tests/lib/libpthread/t_stack.c:1.3 src/tests/lib/libpthread/t_stack.c:1.4 --- src/tests/lib/libpthread/t_stack.c:1.3 Mon Nov 27 22:17:41 2023 +++ src/tests/lib/libpthread/t_stack.c Mon Nov 27 22:18:29 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stack.c,v 1.3 2023/11/27 22:17:41 riastradh Exp $ */ +/* $NetBSD: t_stack.c,v 1.4 2023/11/27 22:18:29 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #define _KMEMUSER /* __MACHINE_STACK_GROWS_UP */ #include -__RCSID("$NetBSD: t_stack.c,v 1.3 2023/11/27 22:17:41 riastradh Exp $"); +__RCSID("$NetBSD: t_stack.c,v 1.4 2023/11/27 22:18:29 riastradh Exp $"); #include #include @@ -216,8 +216,8 @@ checksigsegv(const char *p) memset(&act, 0, sizeof(act)); act.sa_handler = &sigsegv_ok; - pthread_setspecific(C->jmp_key, &j); if (setjmp(j.buf) == 0) { + pthread_setspecific(C->jmp_key, &j); RL(sigaction(SIGSEGV, &act, &oact)); oactsave = oact; v = *p; /* trigger SIGSEGV */ @@ -249,8 +249,8 @@ checknosigsegv(const char *p) memset(&act, 0, sizeof(act)); act.sa_handler = &sigsegv_ok; - pthread_setspecific(C->jmp_key, &j); if (setjmp(j.buf) == 0) { + pthread_setspecific(C->jmp_key, &j); RL(sigaction(SIGSEGV, &act, &oact)); oactsave = oact; v = *p; /* better not trigger SIGSEGV */
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: riastradh Date: Mon Nov 27 22:17:41 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Omit needless cast in previous. Arose from an earlier draft of the change. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libpthread/t_stack.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/libpthread/t_stack.c diff -u src/tests/lib/libpthread/t_stack.c:1.2 src/tests/lib/libpthread/t_stack.c:1.3 --- src/tests/lib/libpthread/t_stack.c:1.2 Mon Nov 27 22:15:08 2023 +++ src/tests/lib/libpthread/t_stack.c Mon Nov 27 22:17:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stack.c,v 1.2 2023/11/27 22:15:08 riastradh Exp $ */ +/* $NetBSD: t_stack.c,v 1.3 2023/11/27 22:17:41 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #define _KMEMUSER /* __MACHINE_STACK_GROWS_UP */ #include -__RCSID("$NetBSD: t_stack.c,v 1.2 2023/11/27 22:15:08 riastradh Exp $"); +__RCSID("$NetBSD: t_stack.c,v 1.3 2023/11/27 22:17:41 riastradh Exp $"); #include #include @@ -169,7 +169,7 @@ init(size_t stacksize) C->size = stacksize; C->guardsize = getdefaultguardsize(); - C->addr = (char *)alloc(C->size + C->guardsize); + C->addr = alloc(C->size + C->guardsize); RZ(pthread_key_create(&C->jmp_key, NULL)); }
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: riastradh Date: Mon Nov 27 22:17:41 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Omit needless cast in previous. Arose from an earlier draft of the change. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libpthread/t_stack.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/libpthread
Module Name:src Committed By: riastradh Date: Mon Nov 27 22:15:08 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Make this more robust to the guard size bug. Make sure to allocate enough space for the thread's stack for a guard even though there shouldn't be one, so that when we run the thread, it doesn't start with the stack pointer pointing into someone else's allocation (like malloc) causing stack frames to trash another data structure -- or causing the user of that data structure to trash the stack frames. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libpthread/t_stack.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/libpthread/t_stack.c diff -u src/tests/lib/libpthread/t_stack.c:1.1 src/tests/lib/libpthread/t_stack.c:1.2 --- src/tests/lib/libpthread/t_stack.c:1.1 Fri Nov 24 16:21:17 2023 +++ src/tests/lib/libpthread/t_stack.c Mon Nov 27 22:15:08 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stack.c,v 1.1 2023/11/24 16:21:17 riastradh Exp $ */ +/* $NetBSD: t_stack.c,v 1.2 2023/11/27 22:15:08 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -29,11 +29,15 @@ #define _KMEMUSER /* __MACHINE_STACK_GROWS_UP */ #include -__RCSID("$NetBSD: t_stack.c,v 1.1 2023/11/24 16:21:17 riastradh Exp $"); +__RCSID("$NetBSD: t_stack.c,v 1.2 2023/11/27 22:15:08 riastradh Exp $"); #include +#include +#include #include +#include /* VM_THREAD_GUARD_SIZE */ + #include #include #include @@ -52,6 +56,7 @@ struct jmp_ctx { */ struct ctx { size_t size; /* default stack size */ + size_t guardsize; /* default guard size */ void *addr; /* user-allocated stack */ pthread_key_t jmp_key; /* jmp_ctx to return from SIGSEGV handler */ } ctx, *C = &ctx; @@ -101,6 +106,34 @@ getnondefaultstacksize(void) } /* + * getdefaultguardsize() + * + * Return the default guard size for threads created with + * pthread_create. + */ +static size_t +getdefaultguardsize(void) +{ + const int mib[2] = { CTL_VM, VM_THREAD_GUARD_SIZE }; + unsigned guardsize; + size_t len = sizeof(guardsize); + + RL(sysctl(mib, __arraycount(mib), &guardsize, &len, NULL, 0)); + ATF_REQUIRE_EQ_MSG(len, sizeof(guardsize), + "len=%zu sizeof(guardsize)=%zu", len, sizeof(guardsize)); + + /* + * Verify this matches what libpthread determined. + */ + extern size_t pthread__guardsize; /* pthread_int.h */ + ATF_CHECK_EQ_MSG(guardsize, pthread__guardsize, + "guardsize=%zu pthread__guardsize=%zu", + guardsize, pthread__guardsize); + + return guardsize; +} + +/* * alloc(nbytes) * * Allocate an nbytes-long page-aligned read/write region and @@ -124,17 +157,35 @@ alloc(size_t nbytes) * * Initialize state used by various tests with the specified * stacksize. + * + * Make sure to allocate enough space that even if there shouldn't + * be a stack guard (i.e., it should be empty), adjusting the + * requested bounds by the default stack guard size will leave us + * inside allocated memory. */ static void init(size_t stacksize) { C->size = stacksize; - C->addr = alloc(C->size); + C->guardsize = getdefaultguardsize(); + C->addr = (char *)alloc(C->size + C->guardsize); RZ(pthread_key_create(&C->jmp_key, NULL)); } /* + * stack_pointer() + * + * Return the stack pointer. This is used to verify whether the + * stack pointer lie within a certain address range. + */ +static __noinline void * +stack_pointer(void) +{ + return __builtin_frame_address(0); +} + +/* * sigsegv_ok(signo) * * Signal handler for SIGSEGV to return to the jmp ctx, to verify @@ -276,10 +327,37 @@ checkaddraccessthread(void *cookie) { pthread_t t = pthread_self(); pthread_attr_t attr; + void *sp; void *addr; size_t size, size0; /* + * Verify the stack pointer lies somewhere in the allocated + * range. + */ + sp = stack_pointer(); + ATF_CHECK_MSG(C->addr <= sp, "sp=%p not in [%p,%p + 0x%zu) = [%p,%p)", + sp, C->addr, C->addr, C->size, C->addr, (char *)C->addr + C->size); + ATF_CHECK_MSG(sp <= (void *)((char *)C->addr + C->size), + "sp=%p not in [%p,%p + 0x%zu) = [%p,%p)", + sp, C->addr, C->addr, C->size, C->addr, (char *)C->addr + C->size); + + /* + * Verify, if not that, then the stack pointer at least lies + * within the extra buffer we allocated for slop to address a + * bug NetBSD libpthread used to have of spuriously adding the + * guard size to a user-allocated stack address. This is + * ATF_REQUIRE, not ATF_CHECK, because if this doesn't hold, we + * might be clobbering some other memory like malloc pages, + * causing the whole test to crash with useless diagnostics. + */ + ATF_REQUIRE_MSG(sp <= (void *)((char *)C->addr + C->size + + C->guardsize), + "sp=%p not even in buffer [%p,%p + 0x%zu + 0x%zu) = [%p,%p)", + sp, C->a
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: riastradh Date: Mon Nov 27 22:15:08 UTC 2023 Modified Files: src/tests/lib/libpthread: t_stack.c Log Message: libpthread/t_stack: Make this more robust to the guard size bug. Make sure to allocate enough space for the thread's stack for a guard even though there shouldn't be one, so that when we run the thread, it doesn't start with the stack pointer pointing into someone else's allocation (like malloc) causing stack frames to trash another data structure -- or causing the user of that data structure to trash the stack frames. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libpthread/t_stack.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/libpthread
Module Name:src Committed By: kre Date: Sun Dec 11 10:02:53 UTC 2022 Modified Files: src/tests/lib/libpthread: t_condwait.c Log Message: This test makes (made) a false assumption about the way that process scheduling works. That a process (or in this case, a thread) is no longer blocked at time T does not mean that it will resume execution at time T. The OS is free to devote resources to other processes/threads instead - all we should normally be able to expect is that if it is not unblocked before time T, that it will not start running before then. In general though, the pthread_cond_*wait() functions don't guarantee even that - but for this test, the possibility of something else randomly signalling the condvar isn't believable, so don't worry about that possibility (but do fail without calling strerror(0) on the off chance it does happen). Once we cease testing that the process resumed running before some particular time, we can stop dealing with qemu timekeeping issues, it might (seem to) take qemu twice as long as was requested before the thread resumes, but that's OK - the same thing could happen on a loaded system for other reasons. Beyond that, the test also has (had) a race condition. When using CLOCK_REALTIME though that clock needed to have advanced to T before the ETIMEDOUT should happen, there is no guarantee that it will stay >T (CLOCK_REALTIME is allowed to be reset backwards). So, only test that the current time (after ETIMEDOUT) >= T when we're using CLOCK_MONOTONIC - for CLOCK_REALTIME the time might have stepped back between when the ETIMEDOUT happened and when the thread obtains the current clock reading. For that case, all we can test is that the ETIMEDOUT actually happens. With much of what was there now gone, the code can be simplified, we no longer need to do timespec arithmetic, just one comparison (simpler to test that Tend >= Tstart+period than Tend-Tstart > period as we need Tstart+period for the abstime value for the timeout anyway). Note that this still tests for the issue reported in PR lib/47703 which is where the test came from in the first place. ps: we seem to be missing pthread_cond_clockwait() which is the same as pthread_cond_timedwait() except that the clock to use is passed as a parameter, rather than as an attribute of the condition variable. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libpthread/t_condwait.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/libpthread/t_condwait.c diff -u src/tests/lib/libpthread/t_condwait.c:1.9 src/tests/lib/libpthread/t_condwait.c:1.10 --- src/tests/lib/libpthread/t_condwait.c:1.9 Sat Apr 16 18:15:22 2022 +++ src/tests/lib/libpthread/t_condwait.c Sun Dec 11 10:02:53 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_condwait.c,v 1.9 2022/04/16 18:15:22 andvar Exp $ */ +/* $NetBSD: t_condwait.c,v 1.10 2022/12/11 10:02:53 kre Exp $ */ /* * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_condwait.c,v 1.9 2022/04/16 18:15:22 andvar Exp $"); +__RCSID("$NetBSD: t_condwait.c,v 1.10 2022/12/11 10:02:53 kre Exp $"); #include #include @@ -50,7 +50,7 @@ static const int debug = 1; static void * run(void *param) { - struct timespec ts, to, te, twmin, twmax; + struct timespec ts, to, te; clockid_t clck; pthread_condattr_t attr; pthread_cond_t cond; @@ -78,30 +78,18 @@ run(void *param) case ETIMEDOUT: /* Timeout */ ATF_REQUIRE_EQ(clock_gettime(clck, &te), 0); - timespecsub(&te, &to, &to); if (debug) { printf("timeout: %lld.%09ld sec\n", (long long)te.tv_sec, te.tv_nsec); + timespecsub(&te, &to, &to); printf("elapsed: %lld.%09ld sec\n", (long long)to.tv_sec, to.tv_nsec); } - twmin.tv_sec = WAITTIME; - twmin.tv_nsec = 0; - if (isQEMU()) { - struct timespec td, t; - // td.tv_sec = 0; - // td.tv_nsec = 9; - t = twmin; - // timespecsub(&t, &td, &twmin); - td.tv_sec = 2; - td.tv_nsec = 5; - timespecadd(&t, &td, &twmax); - } else { - twmax = twmin; - twmax.tv_sec++; - } - ATF_REQUIRE(timespeccmp(&to, &twmin, >=)); - ATF_REQUIRE(timespeccmp(&to, &twmax, <=)); + if (clck == CLOCK_MONOTONIC) + ATF_REQUIRE(timespeccmp(&te, &ts, >=)); + break; + case 0: + atf_tc_fail("pthread_cond_timedwait returned before timeout"); break; default: ATF_REQUIRE_MSG(0, "pthread_cond_timedwait: %s", strerror(ret));
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: kre Date: Sun Dec 11 10:02:53 UTC 2022 Modified Files: src/tests/lib/libpthread: t_condwait.c Log Message: This test makes (made) a false assumption about the way that process scheduling works. That a process (or in this case, a thread) is no longer blocked at time T does not mean that it will resume execution at time T. The OS is free to devote resources to other processes/threads instead - all we should normally be able to expect is that if it is not unblocked before time T, that it will not start running before then. In general though, the pthread_cond_*wait() functions don't guarantee even that - but for this test, the possibility of something else randomly signalling the condvar isn't believable, so don't worry about that possibility (but do fail without calling strerror(0) on the off chance it does happen). Once we cease testing that the process resumed running before some particular time, we can stop dealing with qemu timekeeping issues, it might (seem to) take qemu twice as long as was requested before the thread resumes, but that's OK - the same thing could happen on a loaded system for other reasons. Beyond that, the test also has (had) a race condition. When using CLOCK_REALTIME though that clock needed to have advanced to T before the ETIMEDOUT should happen, there is no guarantee that it will stay >T (CLOCK_REALTIME is allowed to be reset backwards). So, only test that the current time (after ETIMEDOUT) >= T when we're using CLOCK_MONOTONIC - for CLOCK_REALTIME the time might have stepped back between when the ETIMEDOUT happened and when the thread obtains the current clock reading. For that case, all we can test is that the ETIMEDOUT actually happens. With much of what was there now gone, the code can be simplified, we no longer need to do timespec arithmetic, just one comparison (simpler to test that Tend >= Tstart+period than Tend-Tstart > period as we need Tstart+period for the abstime value for the timeout anyway). Note that this still tests for the issue reported in PR lib/47703 which is where the test came from in the first place. ps: we seem to be missing pthread_cond_clockwait() which is the same as pthread_cond_timedwait() except that the clock to use is passed as a parameter, rather than as an attribute of the condition variable. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libpthread/t_condwait.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/libpthread
Module Name:src Committed By: rin Date: Sat May 7 05:13:17 UTC 2022 Modified Files: src/tests/lib/libpthread: t_mutex.c Log Message: Bump timeout for slow machines. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libpthread/t_mutex.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/libpthread/t_mutex.c diff -u src/tests/lib/libpthread/t_mutex.c:1.19 src/tests/lib/libpthread/t_mutex.c:1.20 --- src/tests/lib/libpthread/t_mutex.c:1.19 Fri Dec 1 13:25:29 2017 +++ src/tests/lib/libpthread/t_mutex.c Sat May 7 05:13:17 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_mutex.c,v 1.19 2017/12/01 13:25:29 kre Exp $ */ +/* $NetBSD: t_mutex.c,v 1.20 2022/05/07 05:13:17 rin Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_mutex.c,v 1.19 2017/12/01 13:25:29 kre Exp $"); +__RCSID("$NetBSD: t_mutex.c,v 1.20 2022/05/07 05:13:17 rin Exp $"); #include /* For timespecadd */ #include /* For UINT16_MAX */ @@ -148,6 +148,7 @@ ATF_TC(mutex2); ATF_TC_HEAD(mutex2, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); + atf_tc_set_md_var(tc, "timeout", "600"); } ATF_TC_BODY(mutex2, tc) { @@ -204,6 +205,7 @@ ATF_TC_HEAD(mutex3, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes using a static " "initializer"); + atf_tc_set_md_var(tc, "timeout", "600"); } ATF_TC_BODY(mutex3, tc) {
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: rin Date: Sat May 7 05:13:17 UTC 2022 Modified Files: src/tests/lib/libpthread: t_mutex.c Log Message: Bump timeout for slow machines. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libpthread/t_mutex.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/libpthread
Module Name:src Committed By: martin Date: Sun Aug 11 11:42:23 UTC 2019 Modified Files: src/tests/lib/libpthread: t_condwait.c Log Message: Re-enable the QEMU specific timing limits, but only an increased upper limit for now - let's see if that works on the test-bed. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libpthread/t_condwait.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/libpthread
Module Name:src Committed By: martin Date: Sun Aug 11 11:42:23 UTC 2019 Modified Files: src/tests/lib/libpthread: t_condwait.c Log Message: Re-enable the QEMU specific timing limits, but only an increased upper limit for now - let's see if that works on the test-bed. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libpthread/t_condwait.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/libpthread/t_condwait.c diff -u src/tests/lib/libpthread/t_condwait.c:1.7 src/tests/lib/libpthread/t_condwait.c:1.8 --- src/tests/lib/libpthread/t_condwait.c:1.7 Sat Aug 10 07:36:15 2019 +++ src/tests/lib/libpthread/t_condwait.c Sun Aug 11 11:42:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_condwait.c,v 1.7 2019/08/10 07:36:15 martin Exp $ */ +/* $NetBSD: t_condwait.c,v 1.8 2019/08/11 11:42:23 martin Exp $ */ /* * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_condwait.c,v 1.7 2019/08/10 07:36:15 martin Exp $"); +__RCSID("$NetBSD: t_condwait.c,v 1.8 2019/08/11 11:42:23 martin Exp $"); #include #include @@ -87,12 +87,12 @@ run(void *param) } twmin.tv_sec = WAITTIME; twmin.tv_nsec = 0; - if (0 /* XXX */ && isQEMU()) { + if (isQEMU()) { struct timespec td, t; - td.tv_sec = 0; - td.tv_nsec = 9; + // td.tv_sec = 0; + // td.tv_nsec = 9; t = twmin; - timespecsub(&t, &td, &twmin); + // timespecsub(&t, &td, &twmin); td.tv_sec = 2; td.tv_nsec = 5; timespecadd(&t, &td, &twmax);
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: martin Date: Sat Aug 10 07:36:15 UTC 2019 Modified Files: src/tests/lib/libpthread: t_condwait.c Log Message: PR lib/54440: adapt the FreeBSD change to this test and calculate time differences more exact, allowing between 0 and 1 s delay between the expected wakeup and the actual event happening. Also convert the QEMU special case code to the same scheme, but for now disable it (with XXX mark) and see if the proper timing limits fix that case too. If not, we will re-enable the QEMU special case. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libpthread/t_condwait.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/libpthread/t_condwait.c diff -u src/tests/lib/libpthread/t_condwait.c:1.6 src/tests/lib/libpthread/t_condwait.c:1.7 --- src/tests/lib/libpthread/t_condwait.c:1.6 Tue Jul 9 16:24:01 2019 +++ src/tests/lib/libpthread/t_condwait.c Sat Aug 10 07:36:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_condwait.c,v 1.6 2019/07/09 16:24:01 maya Exp $ */ +/* $NetBSD: t_condwait.c,v 1.7 2019/08/10 07:36:15 martin Exp $ */ /* * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_condwait.c,v 1.6 2019/07/09 16:24:01 maya Exp $"); +__RCSID("$NetBSD: t_condwait.c,v 1.7 2019/08/10 07:36:15 martin Exp $"); #include #include @@ -50,7 +50,7 @@ static const int debug = 1; static void * run(void *param) { - struct timespec ts, to, te; + struct timespec ts, to, te, twmin, twmax; clockid_t clck; pthread_condattr_t attr; pthread_cond_t cond; @@ -85,14 +85,23 @@ run(void *param) printf("elapsed: %lld.%09ld sec\n", (long long)to.tv_sec, to.tv_nsec); } - if (isQEMU()) { - double to_seconds = to.tv_sec + 1e-9 * to.tv_nsec; - ATF_REQUIRE(to_seconds >= WAITTIME * 0.9); - /* Loose upper limit because of qemu timing bugs */ - ATF_REQUIRE(to_seconds < WAITTIME * 2.5); + twmin.tv_sec = WAITTIME; + twmin.tv_nsec = 0; + if (0 /* XXX */ && isQEMU()) { + struct timespec td, t; + td.tv_sec = 0; + td.tv_nsec = 9; + t = twmin; + timespecsub(&t, &td, &twmin); + td.tv_sec = 2; + td.tv_nsec = 5; + timespecadd(&t, &td, &twmax); } else { - ATF_REQUIRE_EQ(to.tv_sec, WAITTIME); + twmax = twmin; + twmax.tv_sec++; } + ATF_REQUIRE(timespeccmp(&to, &twmin, >=)); + ATF_REQUIRE(timespeccmp(&to, &twmax, <=)); break; default: ATF_REQUIRE_MSG(0, "pthread_cond_timedwait: %s", strerror(ret));
CVS commit: src/tests/lib/libpthread
Module Name:src Committed By: martin Date: Sat Aug 10 07:36:15 UTC 2019 Modified Files: src/tests/lib/libpthread: t_condwait.c Log Message: PR lib/54440: adapt the FreeBSD change to this test and calculate time differences more exact, allowing between 0 and 1 s delay between the expected wakeup and the actual event happening. Also convert the QEMU special case code to the same scheme, but for now disable it (with XXX mark) and see if the proper timing limits fix that case too. If not, we will re-enable the QEMU special case. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libpthread/t_condwait.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/libpthread
In article <0c9230c6-d206-5332-d89c-e0b93d3de...@gmx.com>, Kamil Rytarowski wrote: >-=-=-=-=-=- >-=-=-=-=-=- > > > >On 31.10.2016 21:23, Taylor R Campbell wrote: >>Date: Mon, 31 Oct 2016 18:29:56 +0100 >>From: Kamil Rytarowski >> >>pthread_mutex_timedlock(3) is broken and it does not work at all for me, >>not as a standard mutex (like pthread_mutex_lock(3), sufficiently >>lengthy timeout makes it a good approximation) neither as a timed variant. >> >> If the test is expected to fail, you should mark it xfail with a >> reference to a PR so that it doesn't draw needless attention to >> itself. >> >> The autobuild system is designed to detect and flag unexpected >> failures; expected ones should be documented in the PR database >> instead. >> > >You are right, thank you. > >The problem is under investigation right now and is "hot". I have a patch for it: http://www.netbsd.org/~christos/deadlock.diff And a standalone program that reproduces it (from the test): http://www.netbsd.org/~christos/deadlock.c christos
Re: CVS commit: src/tests/lib/libpthread
On 31.10.2016 21:23, Taylor R Campbell wrote: >Date: Mon, 31 Oct 2016 18:29:56 +0100 >From: Kamil Rytarowski > >pthread_mutex_timedlock(3) is broken and it does not work at all for me, >not as a standard mutex (like pthread_mutex_lock(3), sufficiently >lengthy timeout makes it a good approximation) neither as a timed variant. > > If the test is expected to fail, you should mark it xfail with a > reference to a PR so that it doesn't draw needless attention to > itself. > > The autobuild system is designed to detect and flag unexpected > failures; expected ones should be documented in the PR database > instead. > You are right, thank you. The problem is under investigation right now and is "hot". signature.asc Description: OpenPGP digital signature
Re: CVS commit: src/tests/lib/libpthread
Date: Mon, 31 Oct 2016 18:29:56 +0100 From: Kamil Rytarowski pthread_mutex_timedlock(3) is broken and it does not work at all for me, not as a standard mutex (like pthread_mutex_lock(3), sufficiently lengthy timeout makes it a good approximation) neither as a timed variant. If the test is expected to fail, you should mark it xfail with a reference to a PR so that it doesn't draw needless attention to itself. The autobuild system is designed to detect and flag unexpected failures; expected ones should be documented in the PR database instead.
Re: CVS commit: src/tests/lib/libpthread
On 31.10.2016 17:21, Christos Zoulas wrote: > Module Name: src > Committed By: christos > Date: Mon Oct 31 16:21:23 UTC 2016 > > Modified Files: > src/tests/lib/libpthread: t_mutex.c t_timedmutex.c > > Log Message: > Merge and fix the timed mutex tests to use absolute time. > NB: the new tests are broken? > > Tests are good. pthread_mutex_timedlock(3) is broken and it does not work at all for me, not as a standard mutex (like pthread_mutex_lock(3), sufficiently lengthy timeout makes it a good approximation) neither as a timed variant. signature.asc Description: OpenPGP digital signature
Re: CVS commit: src/tests/lib/libpthread
On Sun, Jul 18, 2010 at 11:30 PM, Antti Kantee wrote: > Module Name: src > Committed By: pooka > Date: Sun Jul 18 22:30:55 UTC 2010 > > Modified Files: > src/tests/lib/libpthread: t_sem.c > > Log Message: > Reduce sleep time for practically the same effect. Until atf can > do parallel test execution, tests which spend 99.% of their > execution sleeping are not nice. Thanks. Tests that do any sleep() at all are horrible regardless of whether atf supports parallel execution or not. (Yeah, you can blame me for this one, but I was just copying code! ;-) -- Julio Merino