6424123: JVM crashes on failed 'strdup' call

Calling os::malloc()/os::strdup() and new os::strdup_check_oom() instead of ::malloc()/::strdup() for native memory tracking purpose

Reviewed-by: coleenp, ctornqvi, kvn
This commit is contained in:
Zhengyu Gu 2014-08-11 10:18:09 -07:00
parent 69e7c05210
commit 8a690a1250
20 changed files with 82 additions and 36 deletions

View file

@ -629,10 +629,16 @@ class vmNode : public ProfilerNode {
}
vmNode(const char* name, const TickPosition where) : ProfilerNode() {
_name = name;
_name = os::strdup(name);
update(where);
}
~vmNode() {
if (_name != NULL) {
os::free((void*)_name);
}
}
const char *name() const { return _name; }
bool is_compiled() const { return true; }
@ -784,7 +790,7 @@ void ThreadProfiler::vm_update(const char* name, TickPosition where) {
assert(index >= 0, "Must be positive");
// Note that we call strdup below since the symbol may be resource allocated
if (!table[index]) {
table[index] = new (this) vmNode(os::strdup(name), where);
table[index] = new (this) vmNode(name, where);
} else {
ProfilerNode* prev = table[index];
for(ProfilerNode* node = prev; node; node = node->next()) {
@ -794,7 +800,7 @@ void ThreadProfiler::vm_update(const char* name, TickPosition where) {
}
prev = node;
}
prev->set_next(new (this) vmNode(os::strdup(name), where));
prev->set_next(new (this) vmNode(name, where));
}
}