RFR: 8318302: ThreadCountLimit.java failed with "Native memory allocation (mprotect) failed to protect 16384 bytes for memory to guard stack pages" [v3]
David Holmes
dholmes at openjdk.org
Tue Feb 27 12:14:15 UTC 2024
> The test tries to create as many threads as possible in 5 seconds, with the intention of hitting platform limits on the maximum number of threads that can be created, so that we see that the VM reacts in a reasonable way. However on Linux, if the thread creation limit is high enough, and things run fast enough, then we can instead hit a fatal error when a mmap/mprotect returns E_NOMEM because the maximum number of memory mappings (default 65530) has been exceeded.
>
> The fix to the test (courtesy @stefank ) is to re-exec the test on Linux with `ulimit -u` set to a much smaller value than the default (I chose 4096 as it still showed over 2000 threads were created before failure). This means we are unlikely to hit the default memory mapping limit before we hit the max threads limit.
>
> I also updated the VM's OOM error message to include exceeding the maximum number of memory mappings as a possible cause (with a hint as to what to look for in the hs_err log).
>
> Testing:
> - ran the test 10x on all platforms in our CI (plus local testing)
>
> Thanks
David Holmes has updated the pull request incrementally with one additional commit since the last revision:
Style nit
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/17959/files
- new: https://git.openjdk.org/jdk/pull/17959/files/263c7c41..addf08d8
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=17959&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=17959&range=01-02
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/17959.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17959/head:pull/17959
PR: https://git.openjdk.org/jdk/pull/17959
More information about the hotspot-dev
mailing list