[Bug 234775] PTHREAD_STACK_MIN is too small on amd64
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Dec 2021 21:11:38 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234775 --- 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 = (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 minimum #!/usr/local/bin/python3.8 import subprocess def binary_search(start, end): while (start <= end): mid = (start + end ) // 2 status = subprocess.run(['./pthread_stack', str(mid)], capture_output=True) if (status.stdout.decode().strip("\n") == "success"): end = mid - 1 else: start = mid + 1 return mid res = 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 -- You are receiving this mail because: You are the assignee for the bug.