Skip to contentSkip to conversation

test instruction

PATCH In review Wenlin Kang 2 participants 3 messages Feb 19, 2019 – Dec 27, 2019

lore
Share & tools
lore
#0 lore raw

cover test instruction

1. Create app program, the content similar to:

   	JNIEnv *env = NULL;
	JavaVM *jvm = NULL;

	JavaVMInitArgs vm_args;
	vm_args.version = JNI_VERSION_1_2;
	vm_args.options = NULL;
	vm_args.nOptions = 0;
	vm_args.ignoreUnrecognized = JNI_TRUE;

	jint res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
	if ( ( res == JNI_OK ) && ( jvm != NULL ) )
	{
		jvm->DestroyJavaVM();
	}

2. Create a shell script to run continually this app on a powerPC target(e.g. qemuppc).

3. It will get randomly a segment.

Note: I used jdk8u_72b05 on qemuppc, for 172b11, because I can't build to pass on ppc, I don't test it, but I think this problem should be exist on latest version too.

Wenlin Kang (1):
openjdk: fix a random crash on JNI_CreateJavaVM

 .../openjdk-8-release-172b11-common.inc       |  1 +
 ...otspot-fix-crash-on-JNI_CreateJavaVM.patch | 36 +++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 recipes-core/openjdk/patches-openjdk-8/0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 openjdk: fix a random crash on JNI_CreateJavaVM

When call JNI_CreateJavaVM API, sometimes it will crash(we have reproduced it on quemuppc), this patch fixes it.

---
 .../openjdk-8-release-172b11-common.inc       |  1 +
 ...otspot-fix-crash-on-JNI_CreateJavaVM.patch | 36 +++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 recipes-core/openjdk/patches-openjdk-8/0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch
recipes-core/openjdk/openjdk-8-release-172b11-common.inc +1 -0
index ad20585..b37608c 100644
@@ -21,6 +21,7 @@ PATCHES_URI = "\
     ${LIBPNG_NEON_PATCH} \
     file://handle_extra_output.patch \
     file://hotspot-handle-gcc7-format-overflow.patch \
+    file://0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch \
 "
 HOTSPOT_UB_PATCH = "\
     file://0014-hotspot-zero-fix-undefined-behaviour-gcc-v8-fix.patch \
recipes-core/openjdk/patches-openjdk-8/0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch new file +36 -0
new file mode 100644
index 0000000..4618b6b
@@ -0,0 +1,36 @@
+From d0ebd6f108df9b0f9533de6f16280ceec136d8e6 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <[email protected]>
+Date: Sun, 17 Feb 2019 22:38:33 -0800
+Subject: [PATCH] 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 <[email protected]>
+---
+ hotspot/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 044a70a6..b8246ce4 100644
+--- a/hotspot/src/os/linux/vm/os_linux.cpp
++++ b/hotspot/src/os/linux/vm/os_linux.cpp
+@@ -3078,7 +3078,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.17.1
+
Signature · 1 line
2.17.1
#2 lore raw

Re: [meta-java][PATCH 1/1] openjdk: fix a random crash on JNI_CreateJavaVM

Hi,
this is a note to let you know that I've just added this patch to the master-next branch of the meta-java repository at
git://git.yoctoproject.org/meta-java

As soon as it has gone through some more testing it will likely be merged to the master branch.

If you have any questions, please let me know.

regards;Richard.L

Quoted 65 lines · Wenlin Kang

When call JNI_CreateJavaVM API, sometimes it will crash(we have reproduced it on quemuppc), this patch fixes it.

---
  .../openjdk-8-release-172b11-common.inc       |  1 +
  ...otspot-fix-crash-on-JNI_CreateJavaVM.patch | 36 +++++++++++++++++++
  2 files changed, 37 insertions(+)

create mode 100644 recipes-core/openjdk/patches-openjdk-8/0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch

recipes-core/openjdk/openjdk-8-release-172b11-common.inc +1 -0
index ad20585..b37608c 100644
@@ -21,6 +21,7 @@ PATCHES_URI = "\
      ${LIBPNG_NEON_PATCH} \
      file://handle_extra_output.patch \
      file://hotspot-handle-gcc7-format-overflow.patch \
+    file://0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch \
  "
  HOTSPOT_UB_PATCH = "\
      file://0014-hotspot-zero-fix-undefined-behaviour-gcc-v8-fix.patch \
recipes-core/openjdk/patches-openjdk-8/0001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch new file +36 -0
new file mode 100644
index 0000000..4618b6b
@@ -0,0 +1,36 @@
+From d0ebd6f108df9b0f9533de6f16280ceec136d8e6 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <[email protected]>
+Date: Sun, 17 Feb 2019 22:38:33 -0800
+Subject: [PATCH] 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 <[email protected]>
+---
+ hotspot/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 044a70a6..b8246ce4 100644
+--- a/hotspot/src/os/linux/vm/os_linux.cpp
++++ b/hotspot/src/os/linux/vm/os_linux.cpp
+@@ -3078,7 +3078,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.17.1
+