While working on JDK-8335362 I found that the way we create the "guard zone" (red zone + yellow zone + reserved zone) doesn't seem correct on Windows. These pages are guarded using VirtualProtect() with PAGE_GUARD as memory protection attribute (see StackOverflow::create_stack_guard_pages()). But from testing I checked that accessing a page with this protection attribute will be handled directly by the OS as explained in JDK-8335362, and not by our signal handler. The reason why it's currently working is because it seems that Windows checks there are at least 4 pages below the current guarded one and if not we get an EXCEPTION_STACK_OVERFLOW exception. Currently for Windows DEFAULT_STACK_RED_PAGES=1, DEFAULT_STACK_YELLOW_PAGES=3, and DEFAULT_STACK_RESERVED_PAGES=0. So if we access the first page of the guard zone, below it there will only be 3 more pages, so we do get an EXCEPTION_STACK_OVERFLOW. But increasing the sizes of this zones makes touching the top page of the guard zone unnoticeable.
- duplicates
-
JDK-8067946 StackYellowPages and StackRedPages have no effect on Windows
- Closed