make remove_stack_guard_pages return void

This commit is contained in:
Robert Toyonaga 2026-01-27 17:24:27 -05:00
parent 2c7116ea71
commit 21e0a63e52
6 changed files with 11 additions and 18 deletions

View File

@ -1733,10 +1733,9 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
return true; return true;
} }
bool os::remove_stack_guard_pages(char* addr, size_t size) { void os::remove_stack_guard_pages(char* addr, size_t size) {
// Do not call this; no need to commit stack pages on AIX. // Do not call this; no need to commit stack pages on AIX.
ShouldNotReachHere(); ShouldNotReachHere();
return true;
} }
void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) { void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) {

View File

@ -1763,9 +1763,8 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
// If this is a growable mapping, remove the guard pages entirely by // If this is a growable mapping, remove the guard pages entirely by
// munmap()ping them. If not, just call uncommit_memory(). // munmap()ping them. If not, just call uncommit_memory().
bool os::remove_stack_guard_pages(char* addr, size_t size) { void os::remove_stack_guard_pages(char* addr, size_t size) {
os::uncommit_memory(addr, size, false); os::uncommit_memory(addr, size, false);
return true;
} }
// 'requested_addr' is only treated as a hint, the return value may or // 'requested_addr' is only treated as a hint, the return value may or

View File

@ -3566,14 +3566,15 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
// It's safe to always unmap guard pages for primordial thread because we // It's safe to always unmap guard pages for primordial thread because we
// always place it right after end of the mapped region. // always place it right after end of the mapped region.
bool os::remove_stack_guard_pages(char* addr, size_t size) { void os::remove_stack_guard_pages(char* addr, size_t size) {
uintptr_t stack_extent, stack_base;
if (os::is_primordial_thread()) { if (os::is_primordial_thread()) {
return ::munmap(addr, size) == 0; if (::munmap(addr, size) != 0) {
fatal("Failed to munmap " RANGEFMT, RANGEFMTARGS(addr, size));
}
return;
} }
os::uncommit_memory(addr, size, false); os::uncommit_memory(addr, size, false);
return true;
} }
// 'requested_addr' is only treated as a hint, the return value may or // 'requested_addr' is only treated as a hint, the return value may or

View File

@ -3656,9 +3656,8 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
return os::commit_memory(addr, size, !ExecMem); return os::commit_memory(addr, size, !ExecMem);
} }
bool os::remove_stack_guard_pages(char* addr, size_t size) { void os::remove_stack_guard_pages(char* addr, size_t size) {
os::uncommit_memory(addr, size, false); os::uncommit_memory(addr, size, false);
return true;
} }
static bool protect_pages_individually(char* addr, size_t bytes, unsigned int p, DWORD *old_status) { static bool protect_pages_individually(char* addr, size_t bytes, unsigned int p, DWORD *old_status) {

View File

@ -515,7 +515,7 @@ class os: AllStatic {
static bool unguard_memory(char* addr, size_t bytes); static bool unguard_memory(char* addr, size_t bytes);
static bool create_stack_guard_pages(char* addr, size_t bytes); static bool create_stack_guard_pages(char* addr, size_t bytes);
static bool pd_create_stack_guard_pages(char* addr, size_t bytes); static bool pd_create_stack_guard_pages(char* addr, size_t bytes);
static bool remove_stack_guard_pages(char* addr, size_t bytes); static void remove_stack_guard_pages(char* addr, size_t bytes);
// Helper function to create a new file with template jvmheap.XXXXXX. // Helper function to create a new file with template jvmheap.XXXXXX.
// Returns a valid fd on success or else returns -1 // Returns a valid fd on success or else returns -1
static int create_file_for_heap(const char* dir); static int create_file_for_heap(const char* dir);

View File

@ -116,13 +116,8 @@ void StackOverflow::remove_stack_guard_pages() {
size_t len = stack_guard_zone_size(); size_t len = stack_guard_zone_size();
if (os::must_commit_stack_guard_pages()) { if (os::must_commit_stack_guard_pages()) {
if (os::remove_stack_guard_pages((char *) low_addr, len)) { os::remove_stack_guard_pages((char *) low_addr, len);
_stack_guard_state = stack_guard_unused; _stack_guard_state = stack_guard_unused;
} else {
log_warning(os, thread)("Attempt to deallocate stack guard pages failed ("
PTR_FORMAT "-" PTR_FORMAT ").", p2i(low_addr), p2i(low_addr + len));
return;
}
} else { } else {
if (_stack_guard_state == stack_guard_unused) return; if (_stack_guard_state == stack_guard_unused) return;
if (os::unguard_memory((char *) low_addr, len)) { if (os::unguard_memory((char *) low_addr, len)) {