GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — gh-159320: use pthread_getattr_np for stack limit checks even on musl by Yhg1s · Pull Request #159376 · python/cpython Conversation
|
|
This is a more general fix than #159321, and incidentally also lets us have proper stack overflow protections on musl. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
For the record, I think this should not be backported. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…doesn't depend on explicitly setting the stack size. It's correct for new threads regardless of that call.
|
Can you please make the new "HAVE" macro private? Replace the macro in configure.ac: - [AC_DEFINE([HAVE_UNRELIABLE_PTHREAD_GETATTR_NP], [1], + [AC_DEFINE([_Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP], [1], Something like that: Detailsdiff --git a/Python/ceval.c b/Python/ceval.c index 3ed070a5846..e0623293670 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -65,7 +65,7 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count) # define Py_C_STACK_SIZE 4000000 #endif -#ifdef HAVE_UNRELIABLE_PTHREAD_GETATTR_NP +#ifdef _Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP #ifdef HAVE_SYS_RESOURCE_H # include <sys/resource.h> #endif @@ -165,7 +165,7 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp) err |= pthread_attr_destroy(&attr); } if (err == 0) { -# ifdef HAVE_UNRELIABLE_PTHREAD_GETATTR_NP +# ifdef _Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP /* pthread_getattr_np on the main thread of a musl process reports a * stack size based on the current stack rather than RLIMIT_STACK. * New threads are reported correctly even on musl, so this fallback diff --git a/Tools/build/check_capi_macros_ignored.txt b/Tools/build/check_capi_macros_ignored.txt index cfa37c2b137..238c29b7039 100644 --- a/Tools/build/check_capi_macros_ignored.txt +++ b/Tools/build/check_capi_macros_ignored.txt @@ -627,7 +627,6 @@ HAVE_UNAME HAVE_UNISTD_H HAVE_UNLINKAT HAVE_UNLOCKPT -HAVE_UNRELIABLE_PTHREAD_GETATTR_NP HAVE_UNSHARE HAVE_USABLE_WCHAR_T HAVE_UTIL_H diff --git a/configure b/configure index 221907add48..744ee2beef4 100755 --- a/configure +++ b/configure @@ -21875,7 +21875,7 @@ printf "%s\n" "$ac_cv_unreliable_pthread_getattr_np" >&6; } if test "x$ac_cv_unreliable_pthread_getattr_np" = xyes then : -printf "%s\n" "#define HAVE_UNRELIABLE_PTHREAD_GETATTR_NP 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP 1" >>confdefs.h fi fi diff --git a/configure.ac b/configure.ac index e523314b492..42844ab64ca 100644 --- a/configure.ac +++ b/configure.ac @@ -5620,7 +5620,7 @@ int main(void) { [ac_cv_unreliable_pthread_getattr_np=yes], [ac_cv_unreliable_pthread_getattr_np=no])]) AS_VAR_IF([ac_cv_unreliable_pthread_getattr_np], [yes], - [AC_DEFINE([HAVE_UNRELIABLE_PTHREAD_GETATTR_NP], [1], + [AC_DEFINE([_Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP], [1], [Define if pthread_getattr_np under-reports the main thread's stack size (musl behaviour).])])]) # os.statx uses Linux's statx function. AIX also has a function named statx, diff --git a/pyconfig.h.in b/pyconfig.h.in index 4193d536f3b..1fdeb7d9f2f 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1706,10 +1706,6 @@ /* Define to 1 if you have the 'unlockpt' function. */ #undef HAVE_UNLOCKPT -/* Define if pthread_getattr_np under-reports the main thread's stack size - (musl behaviour). */ -#undef HAVE_UNRELIABLE_PTHREAD_GETATTR_NP - /* Define to 1 if you have the 'unshare' function. */ #undef HAVE_UNSHARE @@ -2227,6 +2223,10 @@ /* Define if you have the 'tanpi' function. */ #undef _Py_HAVE_TANPI +/* Define if pthread_getattr_np under-reports the main thread's stack size + (musl behaviour). */ +#undef _Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP + /* Thread stack size set by the linker (in bytes). */ #undef _Py_LINKER_THREAD_STACK_SIZE |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
See also #159604 for FreeBSD. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, this dropped off my radar. I'll resolve the conflict and rename the macro. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @encukou for commit a44a16c 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F159376%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.