Date: Thu, 02 Dec 2021 21:11:38 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 234775] PTHREAD_STACK_MIN is too small on amd64 Message-ID: <bug-234775-227-seo9m2PMUj@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-234775-227@https.bugs.freebsd.org/bugzilla/> References: <bug-234775-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D234775 --- Comment #6 from Paul Floyd <pjfloyd@wanadoo.fr> --- I modified the testcase to take the stack size as an argument and print "success" if the thread gets created and joins. #include <limits.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> static void * fn(void *arg __unused) { return (NULL); } int main(int argc, char** argv) { pthread_t t; pthread_attr_t attr; size_t size =3D (size_t)atoi(argv[1]); (void)pthread_attr_init(&attr); /*(void)pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);*/ (void)pthread_attr_setstacksize(&attr, size); (void)pthread_create(&t, &attr, fn, NULL); (void)pthread_join(t, NULL); printf("success\n"); return (0); } then I wrote a little python script to do a binary search to find the minim= um #!/usr/local/bin/python3.8 import subprocess def binary_search(start, end): while (start <=3D end): mid =3D (start + end ) // 2 status =3D subprocess.run(['./pthread_stack', str(mid)], capture_output=3DTrue) if (status.stdout.decode().strip("\n") =3D=3D "success"): end =3D mid - 1 else: start =3D mid + 1 return mid res =3D binary_search(1, 10000) print("res " + str(res)) For an i386 binary compiled with clang -g -o pthread_stack pthread_stack.c -pthread -m32 I get res 2788 and for an amd64 binary (as before but without -m32) I get res 3024 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-234775-227-seo9m2PMUj>