aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-core/openjdk/patches-openjdk-8/1001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch
blob: 280ee609e1dc75ef47a2672eee739d9491969fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 5e8080a8dd56205f550f7c490f864c95dc8e509b Mon Sep 17 00:00:00 2001
From: Wenlin Kang <wenlin.kang@windriver.com>
Date: Sun, 17 Feb 2019 22:38:33 -0800
Subject: [PATCH 1001/1012] hotspot: fix crash on JNI_CreateJavaVM

In function os::pd_create_stack_guard_pages(char* addr, size_t size),
when addr < os::Linux::initial_thread_stack_bottom(), usually munmap()
will not be called, but when mincore()==-1, get_stack_commited_bottom()
will make stack_extent < os::Linux::initial_thread_stack_bottom() and
stack_extent < addr too, then munmap() is called, in such case, it may
cause segment(we have reproduced it on linux_PPC).

Upstream-Status: Pending

Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
---
 src/os/linux/vm/os_linux.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 03cabfefb..4f28cc1fb 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -3192,7 +3192,8 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
     uintptr_t stack_extent = (uintptr_t) os::Linux::initial_thread_stack_bottom();
     unsigned char vec[1];
 
-    if (mincore((address)stack_extent, os::vm_page_size(), vec) == -1) {
+    if ((mincore((address)stack_extent, os::vm_page_size(), vec) == -1)
+        && ((size_t)addr > (size_t)stack_extent)) {
       // Fallback to slow path on all errors, including EAGAIN
       stack_extent = (uintptr_t) get_stack_commited_bottom(
                                     os::Linux::initial_thread_stack_bottom(),
-- 
2.24.1