head 1.1; access; symbols; locks; strict; comment @// @; 1.1 date 2026.08.30.14.25.05; author wiz; state Exp; branches; next ; commitid JBc39jPIQAWHzFTG; desc @@ 1.1 log @www/webkit-gtk41: import webkit-gtk41-2.52.6 WebKit is an open source web browser engine. WebKit is also the name of the Mac OS X system framework version of the engine that's used by Safari, Dashboard, Mail, and many other OS X applications. WebKit's HTML and JavaScript code began as a branch of the KHTML and KJS libraries from KDE. This is the GTK3 port of the engine, API version 4.1. @ text @$NetBSD$ --- Source/WTF/wtf/StackBounds.cpp.orig 2026-02-23 14:40:54.556305400 +0000 +++ Source/WTF/wtf/StackBounds.cpp @@@@ -42,6 +42,14 @@@@ #include #endif +#if OS(NETBSD) +#include +#include +#include +#include +extern "C" struct ps_strings* __ps_strings; +#endif + #if OS(QNX) #include #endif @@@@ -140,6 +148,31 @@@@ StackBounds StackBounds::currentThreadStackBoundsInter StackBounds StackBounds::currentThreadStackBoundsInternal() { auto ret = newThreadStackBounds(pthread_self()); +#if OS(NETBSD) +#if __NetBSD_Version__ < 1199000700 + // Due to a bug in posix_spawn(3), AT_STACKBASE is wrong for the main thread. + // Use __ps_strings to find the top of the stack, and use that if the current + // stack falls in the computed range on affected NetBSD versions. + // https://gnats.netbsd.org/60653 + if (__ps_strings) { +WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN + char* origin = reinterpret_cast(__ps_strings) + sizeof(struct ps_strings); +WTF_ALLOW_UNSAFE_BUFFER_USAGE_END + rlimit limit; + rlim_t size = 8 * MB; + if (!getrlimit(RLIMIT_STACK, &limit) && limit.rlim_cur != RLIM_INFINITY) + size = limit.rlim_cur; +WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN + char* bound = origin - size; +WTF_ALLOW_UNSAFE_BUFFER_USAGE_END + // Only the initial thread lives in that range; everybody else keeps + // the libpthread-reported bounds. + char* here = reinterpret_cast(&limit); + if (here > bound && here < origin) + return StackBounds { origin, bound }; + } +#endif +#endif #if OS(LINUX) // on glibc, pthread_attr_getstack will generally return the limit size (minus a guard page) // for the main thread; this is however not necessarily always true on every libc - for example @