Module Name: src Committed By: riastradh Date: Tue Nov 28 02:54:33 UTC 2023
Modified Files: src/lib/libpthread: pthread.c src/tests/lib/libpthread: t_stack.c Log Message: pthread: Don't adjust user-allocated stack addresses by guardsize. PR lib/57721 XXX pullup-10 XXX pullup-9 XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/lib/libpthread/pthread.c cvs rdiff -u -r1.5 -r1.6 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/lib/libpthread/pthread.c diff -u src/lib/libpthread/pthread.c:1.183 src/lib/libpthread/pthread.c:1.184 --- src/lib/libpthread/pthread.c:1.183 Thu Sep 7 19:59:20 2023 +++ src/lib/libpthread/pthread.c Tue Nov 28 02:54:33 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.183 2023/09/07 19:59:20 ad Exp $ */ +/* $NetBSD: pthread.c,v 1.184 2023/11/28 02:54:33 riastradh Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020 @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread.c,v 1.183 2023/09/07 19:59:20 ad Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.184 2023/11/28 02:54:33 riastradh Exp $"); #define __EXPOSE_STACK 1 @@ -331,7 +331,10 @@ pthread__getstack(pthread_t newthread, c if (attr != NULL) { pthread_attr_getstack(attr, &stackbase, &stacksize); - pthread_attr_getguardsize(attr, &guardsize); + if (stackbase == NULL) + pthread_attr_getguardsize(attr, &guardsize); + else + guardsize = 0; } else { stackbase = NULL; stacksize = 0; Index: src/tests/lib/libpthread/t_stack.c diff -u src/tests/lib/libpthread/t_stack.c:1.5 src/tests/lib/libpthread/t_stack.c:1.6 --- src/tests/lib/libpthread/t_stack.c:1.5 Tue Nov 28 00:27:05 2023 +++ src/tests/lib/libpthread/t_stack.c Tue Nov 28 02:54:33 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stack.c,v 1.5 2023/11/28 00:27:05 riastradh Exp $ */ +/* $NetBSD: t_stack.c,v 1.6 2023/11/28 02:54:33 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #define _KMEMUSER /* __MACHINE_STACK_GROWS_UP */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_stack.c,v 1.5 2023/11/28 00:27:05 riastradh Exp $"); +__RCSID("$NetBSD: t_stack.c,v 1.6 2023/11/28 02:54:33 riastradh Exp $"); #include <sys/mman.h> #include <sys/param.h> @@ -399,15 +399,12 @@ ATF_TC_BODY(stack1, tc) */ init(getnondefaultstacksize()); - /* * Create a thread with user-allocated stack of a non-default * size to verify the stack size and access. */ RZ(pthread_attr_init(&attr)); RZ(pthread_attr_setstack(&attr, C->addr, C->size)); - atf_tc_expect_fail("PR lib/57721: pthread_attr_setstack" - " incorrectly adjusts address as if for guard page"); RZ(pthread_create(&t, &attr, &checkaddraccessthread, C)); RZ(pthread_join(t, NULL)); @@ -464,8 +461,6 @@ ATF_TC_BODY(stack2, tc) */ RZ(pthread_attr_init(&attr2)); RZ(pthread_attr_setstack(&attr2, C->addr, C->size)); - atf_tc_expect_fail("PR lib/57721: pthread_attr_setstack" - " incorrectly adjusts address as if for guard page"); RZ(pthread_create(&t2, &attr2, &checkaddraccessthread, C)); ATF_CHECK_EQ_MSG(t, t2, "t=%p t2=%p", t, t2); /* NetBSD recycles */ RZ(pthread_join(t2, NULL));