On Sun, 30 May 2021 03:00:56 GMT, David Holmes <dhol...@openjdk.org> wrote:
>> …d on macOS >> >> This patch simply round up the specified stack size to multiple of the >> system page size. >> >> Test is trivial, simply run java with -Xss option against following code. On >> MacOS, before the fix, running with `-Xss159k` and `-Xss160k` would get >> `7183` and `649` respectively. After fix, both would output `649`, while >> `-Xss161k` would be same as `-Xss164k` and see 691 as the output. >> >> ```code:java >> public class StackLeak { >> public int depth = 0; >> public void stackLeak() { >> depth++; >> stackLeak(); >> } >> >> public static void main(String[] args) { >> var test = new StackLeak(); >> try { >> test.stackLeak(); >> } catch (Throwable e) { >> System.out.println(test.depth); >> } >> } >> } > > src/java.base/macosx/native/libjli/java_md_macosx.m line 727: > >> 725: >> 726: static size_t alignUp(size_t stack_size) { >> 727: long page_size = sysconf(_SC_PAGESIZE); > > In hotspot we use `getpagesize()`. There is also a guard for a very large > stack (within a page of SIZE_MAX) so that rounding up does not produce zero. sounds like that (getpagesize) should work with m1 mac as well, as they have 16k pages. will it ? ------------- PR: https://git.openjdk.java.net/jdk/pull/4256