8265682: G1: Mutex::_name dangling in HeapRegionRemSet references after JDK-8264146
Reviewed-by: dholmes, sjohanss
This commit is contained in:
parent
2b09ff219e
commit
222f9f07d1
@ -258,6 +258,7 @@ bool Monitor::wait(int64_t timeout) {
|
||||
|
||||
Mutex::~Mutex() {
|
||||
assert_owner(NULL);
|
||||
os::free(const_cast<char*>(_name));
|
||||
}
|
||||
|
||||
// Only Threads_lock and Heap_lock may be safepoint_check_sometimes.
|
||||
@ -266,9 +267,10 @@ bool is_sometimes_ok(const char* name) {
|
||||
}
|
||||
|
||||
Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
|
||||
SafepointCheckRequired safepoint_check_required) : _owner(NULL), _name(name) {
|
||||
SafepointCheckRequired safepoint_check_required) : _owner(NULL) {
|
||||
assert(os::mutex_init_done(), "Too early!");
|
||||
assert(name != NULL, "Mutex requires a name");
|
||||
_name = os::strdup(name, mtInternal);
|
||||
#ifdef ASSERT
|
||||
_allow_vm_block = allow_vm_block;
|
||||
_rank = Rank;
|
||||
|
@ -25,8 +25,32 @@
|
||||
#include "runtime/interfaceSupport.inline.hpp"
|
||||
#include "runtime/mutex.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
#include "utilities/formatBuffer.hpp"
|
||||
#include "threadHelper.inline.hpp"
|
||||
#include "unittest.hpp"
|
||||
|
||||
const int iterations = 10;
|
||||
static Mutex* m[iterations];
|
||||
static int i = 0;
|
||||
|
||||
static void create_mutex(Thread* thr) {
|
||||
m[i] = new Mutex(Mutex::leaf, FormatBuffer<128>("MyLock lock #%u", i), true, Mutex::_safepoint_check_never);
|
||||
i++;
|
||||
}
|
||||
|
||||
TEST_VM(MutexName, mutex_name) {
|
||||
// Create mutexes in threads, where the names are created on the thread
|
||||
// stacks and then check that their names are correct.
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
nomt_test_doer(create_mutex);
|
||||
}
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
FormatBuffer<128> f("MyLock lock #%u", i);
|
||||
ASSERT_STREQ(m[i]->name(), f.buffer()) << "Wrong name!";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
|
||||
const int rankA = 50;
|
Loading…
Reference in New Issue
Block a user