Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTHREAD_STACK_MIN may not be constant #155

Closed
jamesjer opened this issue Jul 23, 2021 · 1 comment · Fixed by #159
Closed

PTHREAD_STACK_MIN may not be constant #155

jamesjer opened this issue Jul 23, 2021 · 1 comment · Fixed by #159

Comments

@jamesjer
Copy link
Contributor

In the upcoming glibc version 2.34, PTHREAD_STACK_MIN will be defined like this if _DYNAMIC_STACK_SIZE_SOURCE is defined (it is enabled by _GNU_SOURCE):

#   define __SC_THREAD_STACK_MIN_VALUE 75
#   define PTHREAD_STACK_MIN __sysconf (__SC_THREAD_STACK_MIN_VALUE)

The glibc maintainers made this change (and a similar change to the definitions of SIGSTKSZ and MINSIGSTKSZ) to deal with CPUs that have varying stack size requirements depending on optional components. This has led to compilation failures for a number of packages, including polyml, due to use of PTHREAD_STACK_MIN in an #if in libpolyml/sighandler.cpp. Are you open to doing a run-time check instead of a compile-time check, something like this?

#ifdef PTHREAD_STACK_MIN
    size_t stacksize = PTHREAD_STACK_MIN; // Only small stack.
    if (stacksize < 4096U) // But not too small; FreeBSD makes it 2k
        stacksize = 4096U;
    pthread_attr_setstacksize(&attrs, stacksize);
#endif
@dcjm
Copy link
Contributor

dcjm commented Aug 8, 2021

That seems sensible. Do you want to provide a pull request for this since you may be able to test it? Include a comment to say that PTHREAD_STACK_MIN may be defined as a function call otherwise there's the possibility that it could be changed back at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants