--- old/src/os/windows/vm/os_windows.cpp 2015-12-21 13:02:53.430187650 -0800 +++ new/src/os/windows/vm/os_windows.cpp 2015-12-21 13:02:53.330187654 -0800 @@ -3423,8 +3423,7 @@ // Use VirtualQuery() to get the chunk size. while (bytes_remaining) { MEMORY_BASIC_INFORMATION alloc_info; - ret = VirtualQuery(next_protect_addr, &alloc_info, sizeof(alloc_info)) != 0; - if (!ret) { + if (VirtualQuery(next_protect_addr, &alloc_info, sizeof(alloc_info)) == 0) { return false; } @@ -3471,7 +3470,14 @@ // Pages in the region become guard pages. Any attempt to access a guard page // causes the system to raise a STATUS_GUARD_PAGE exception and turn off // the guard page status. Guard pages thus act as a one-time access alarm. - bool ret = protect_pages_individually(addr, bytes, p, &old_status); + bool ret; + if (UseNUMAInterleaving) { + // If UseNUMAInterleaving is enabled, the pages may have been allocated a chunk at a time, + // so we must protect the chunks individually. + ret = protect_pages_individually(addr, bytes, p, &old_status); + } else { + ret = VirtualProtect(addr, bytes, p, &old_status) != 0; + } #ifdef ASSERT if (!ret) { int err = os::get_last_error();