aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/utilities
diff options
context:
space:
mode:
authorccheung <none@none>2013-04-30 11:56:52 -0700
committerccheung <none@none>2013-04-30 11:56:52 -0700
commit598c5e1fce0d4d372eee35630c594f7c7e44010b (patch)
treea666334b914f3edcd33215755151895415590a90 /src/share/vm/utilities
parentc7de61dd49b08fdad1035bcfda5f1759bd1a01e1 (diff)
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
Reviewed-by: coleenp, zgu, hseigel
Diffstat (limited to 'src/share/vm/utilities')
-rw-r--r--src/share/vm/utilities/debug.cpp6
-rw-r--r--src/share/vm/utilities/debug.hpp14
-rw-r--r--src/share/vm/utilities/vmError.cpp17
-rw-r--r--src/share/vm/utilities/vmError.hpp11
-rw-r--r--src/share/vm/utilities/workgroup.cpp5
5 files changed, 32 insertions, 21 deletions
diff --git a/src/share/vm/utilities/debug.cpp b/src/share/vm/utilities/debug.cpp
index 5304cf087..a675c27bf 100644
--- a/src/share/vm/utilities/debug.cpp
+++ b/src/share/vm/utilities/debug.cpp
@@ -229,11 +229,11 @@ void report_fatal(const char* file, int line, const char* message)
}
void report_vm_out_of_memory(const char* file, int line, size_t size,
- const char* message) {
+ VMErrorType vm_err_type, const char* message) {
if (Debugging) return;
Thread* thread = ThreadLocalStorage::get_thread_slow();
- VMError(thread, file, line, size, message).report_and_die();
+ VMError(thread, file, line, size, vm_err_type, message).report_and_die();
// The UseOSErrorReporting option in report_and_die() may allow a return
// to here. If so then we'll have to figure out how to handle it.
@@ -344,7 +344,7 @@ void test_error_handler(size_t test_num)
msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
msg, eol, msg, eol, msg, eol, msg, eol, msg));
- case 8: vm_exit_out_of_memory(num, "ChunkPool::allocate");
+ case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
case 9: ShouldNotCallThis();
case 10: ShouldNotReachHere();
case 11: Unimplemented();
diff --git a/src/share/vm/utilities/debug.hpp b/src/share/vm/utilities/debug.hpp
index 0c718a2fe..9a8332feb 100644
--- a/src/share/vm/utilities/debug.hpp
+++ b/src/share/vm/utilities/debug.hpp
@@ -174,9 +174,9 @@ do { \
} while (0)
// out of memory
-#define vm_exit_out_of_memory(size, msg) \
+#define vm_exit_out_of_memory(size, vm_err_type, msg) \
do { \
- report_vm_out_of_memory(__FILE__, __LINE__, size, msg); \
+ report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, msg); \
BREAKPOINT; \
} while (0)
@@ -204,12 +204,20 @@ do { \
BREAKPOINT; \
} while (0);
+
+// types of VM error - originally in vmError.hpp
+enum VMErrorType {
+ INTERNAL_ERROR = 0xe0000000,
+ OOM_MALLOC_ERROR = 0xe0000001,
+ OOM_MMAP_ERROR = 0xe0000002
+};
+
// error reporting helper functions
void report_vm_error(const char* file, int line, const char* error_msg,
const char* detail_msg = NULL);
void report_fatal(const char* file, int line, const char* message);
void report_vm_out_of_memory(const char* file, int line, size_t size,
- const char* message);
+ VMErrorType vm_err_type, const char* message);
void report_should_not_call(const char* file, int line);
void report_should_not_reach_here(const char* file, int line);
void report_unimplemented(const char* file, int line);
diff --git a/src/share/vm/utilities/vmError.cpp b/src/share/vm/utilities/vmError.cpp
index e1608cae9..76fd96c38 100644
--- a/src/share/vm/utilities/vmError.cpp
+++ b/src/share/vm/utilities/vmError.cpp
@@ -100,7 +100,7 @@ VMError::VMError(Thread* thread, const char* filename, int lineno,
const char* message, const char * detail_msg)
{
_thread = thread;
- _id = internal_error; // Value that's not an OS exception/signal
+ _id = INTERNAL_ERROR; // Value that's not an OS exception/signal
_filename = filename;
_lineno = lineno;
_message = message;
@@ -119,9 +119,9 @@ VMError::VMError(Thread* thread, const char* filename, int lineno,
// Constructor for OOM errors
VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size,
- const char* message) {
+ VMErrorType vm_err_type, const char* message) {
_thread = thread;
- _id = oom_error; // Value that's not an OS exception/signal
+ _id = vm_err_type; // Value that's not an OS exception/signal
_filename = filename;
_lineno = lineno;
_message = message;
@@ -142,7 +142,7 @@ VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size,
// Constructor for non-fatal errors
VMError::VMError(const char* message) {
_thread = NULL;
- _id = internal_error; // Value that's not an OS exception/signal
+ _id = INTERNAL_ERROR; // Value that's not an OS exception/signal
_filename = NULL;
_lineno = 0;
_message = message;
@@ -351,9 +351,12 @@ void VMError::report(outputStream* st) {
STEP(15, "(printing type of error)")
switch(_id) {
- case oom_error:
+ case OOM_MALLOC_ERROR:
+ case OOM_MMAP_ERROR:
if (_size) {
- st->print("# Native memory allocation (malloc) failed to allocate ");
+ st->print("# Native memory allocation ");
+ st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
+ "(mmap) failed to map ");
jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
st->print(buf);
st->print(" bytes");
@@ -386,7 +389,7 @@ void VMError::report(outputStream* st) {
return; // that's enough for the screen
}
break;
- case internal_error:
+ case INTERNAL_ERROR:
default:
break;
}
diff --git a/src/share/vm/utilities/vmError.hpp b/src/share/vm/utilities/vmError.hpp
index 5e33b1177..f298c1edb 100644
--- a/src/share/vm/utilities/vmError.hpp
+++ b/src/share/vm/utilities/vmError.hpp
@@ -34,10 +34,6 @@ class VMError : public StackObj {
friend class VM_ReportJavaOutOfMemory;
friend class Decoder;
- enum ErrorType {
- internal_error = 0xe0000000,
- oom_error = 0xe0000001
- };
int _id; // Solaris/Linux signals: 0 - SIGRTMAX
// Windows exceptions: 0xCxxxxxxx system errors
// 0x8xxxxxxx system warnings
@@ -96,9 +92,12 @@ class VMError : public StackObj {
// accessor
const char* message() const { return _message; }
const char* detail_msg() const { return _detail_msg; }
- bool should_report_bug(unsigned int id) { return id != oom_error; }
+ bool should_report_bug(unsigned int id) {
+ return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
+ }
public:
+
// Constructor for crashes
VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
void* context);
@@ -108,7 +107,7 @@ public:
// Constructor for VM OOM errors
VMError(Thread* thread, const char* filename, int lineno, size_t size,
- const char* message);
+ VMErrorType vm_err_type, const char* message);
// Constructor for non-fatal errors
VMError(const char* message);
diff --git a/src/share/vm/utilities/workgroup.cpp b/src/share/vm/utilities/workgroup.cpp
index 3225ccacb..5db6344fd 100644
--- a/src/share/vm/utilities/workgroup.cpp
+++ b/src/share/vm/utilities/workgroup.cpp
@@ -79,7 +79,7 @@ bool WorkGang::initialize_workers() {
}
_gang_workers = NEW_C_HEAP_ARRAY(GangWorker*, total_workers(), mtInternal);
if (gang_workers() == NULL) {
- vm_exit_out_of_memory(0, "Cannot create GangWorker array.");
+ vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array.");
return false;
}
os::ThreadType worker_type;
@@ -93,7 +93,8 @@ bool WorkGang::initialize_workers() {
assert(new_worker != NULL, "Failed to allocate GangWorker");
_gang_workers[worker] = new_worker;
if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
- vm_exit_out_of_memory(0, "Cannot create worker GC thread. Out of system resources.");
+ vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
+ "Cannot create worker GC thread. Out of system resources.");
return false;
}
if (!DisableStartThread) {