1- /* $NetBSD: t_signal_and_sp.c,v 1.13 2025/04/24 23:51:03 riastradh Exp $ */
1+ /* $NetBSD: t_signal_and_sp.c,v 1.14 2025/04/25 00:03:16 riastradh Exp $ */
22
33/*
44 * Copyright (c) 2024 The NetBSD Foundation, Inc.
2727 */
2828
2929#include <sys/cdefs.h>
30- __RCSID ("$NetBSD: t_signal_and_sp.c,v 1.13 2025/04/24 23:51:03 riastradh Exp $" );
30+ __RCSID ("$NetBSD: t_signal_and_sp.c,v 1.14 2025/04/25 00:03:16 riastradh Exp $" );
3131
3232#include <sys/wait.h>
3333
@@ -493,6 +493,8 @@ ATF_TC_HEAD(threadsp, tc)
493493ATF_TC_BODY (threadsp , tc )
494494{
495495#if defined STACK_ALIGNBYTES && defined HAVE_THREADSPFUNC
496+ pthread_t t ;
497+ void * sp ;
496498 char * stack ;
497499 unsigned i ;
498500
@@ -509,10 +511,18 @@ ATF_TC_BODY(threadsp, tc)
509511 " user stack pointer is not aligned properly" );
510512#endif
511513
514+ RZ (pthread_create (& t , NULL , & threadspfunc , NULL ));
515+
516+ alarm (1 );
517+ RZ (pthread_join (t , & sp ));
518+ alarm (0 );
519+
520+ ATF_CHECK (sp != NULL );
521+ ATF_CHECK_MSG (((uintptr_t )sp & STACK_ALIGNBYTES ) == 0 ,
522+ "thread called with misaligned sp: %p" , sp );
523+
512524 for (i = 0 ; i <= STACK_ALIGNBYTES ; i ++ ) {
513- pthread_t t ;
514525 pthread_attr_t attr ;
515- void * sp ;
516526
517527 RZ (pthread_attr_init (& attr ));
518528 RZ (pthread_attr_setstack (& attr , stack , SIGSTKSZ + i ));
@@ -532,9 +542,7 @@ ATF_TC_BODY(threadsp, tc)
532542 }
533543
534544 for (i = 0 ; i <= STACK_ALIGNBYTES ; i ++ ) {
535- pthread_t t ;
536545 pthread_attr_t attr ;
537- void * sp ;
538546
539547 RZ (pthread_attr_init (& attr ));
540548 RZ (pthread_attr_setstack (& attr , stack + i , SIGSTKSZ ));
0 commit comments