8062672: JVM crashes during GC on various asserts which checks that HeapWord ptr is an oop
authorsjohanss
Thu, 11 Dec 2014 09:56:57 +0100
changeset 29210 f8d006dc2485
parent 29209 905a4254b6dd
child 29211 b6362911d8ba
child 29323 1e366d4e5472
8062672: JVM crashes during GC on various asserts which checks that HeapWord ptr is an oop Summary: Crashes were caused by not disabling UseMemSetInBOT as should be done on sparc. Added support for picking up blkinit as a platform feature if available on Linux sparc. This is needed to avoid enabling UseMemSetInBOT when running on this platform. Reviewed-by: jwilhelm, brutisso
hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp
--- a/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp	Mon Feb 23 18:40:04 2015 +0100
+++ b/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp	Thu Dec 11 09:56:57 2014 +0100
@@ -26,8 +26,8 @@
 #include "runtime/os.hpp"
 #include "vm_version_sparc.hpp"
 
-static bool detect_niagara() {
-  char cpu[128];
+static bool cpuinfo_field_contains(const char* field, const char* value) {
+  char line[1024];
   bool rv = false;
 
   FILE* fp = fopen("/proc/cpuinfo", "r");
@@ -35,9 +35,10 @@
     return rv;
   }
 
-  while (!feof(fp)) {
-    if (fscanf(fp, "cpu\t\t: %100[^\n]", cpu) == 1) {
-      if (strstr(cpu, "Niagara") != NULL) {
+  while (fgets(line, sizeof(line), fp) != NULL) {
+    assert(strlen(line) < sizeof(line) - 1, "buffer line[1024] is too small.");
+    if (strncmp(line, field, strlen(field)) == 0) {
+      if (strstr(line, value) != NULL) {
         rv = true;
       }
       break;
@@ -45,8 +46,15 @@
   }
 
   fclose(fp);
+  return rv;
+}
 
-  return rv;
+static bool detect_niagara() {
+  return cpuinfo_field_contains("cpu", "Niagara");
+}
+
+static bool detect_blkinit() {
+  return cpuinfo_field_contains("cpucaps", "blkinit");
 }
 
 int VM_Version::platform_features(int features) {
@@ -58,5 +66,9 @@
     features = niagara1_m | T_family_m;
   }
 
+  if (detect_blkinit()) {
+    features |= blk_init_instructions_m;
+  }
+
   return features;
 }