Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8265682: G1: Mutex::_name dangling in HeapRegionRemSet references after JDK-8264146 #3639

wants to merge 2 commits into from
Changes from all commits
File filter

Filter by extension

Filter by extension

Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -258,6 +258,7 @@ bool Monitor::wait(int64_t timeout) {

Mutex::~Mutex() {

// 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);

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++) {
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;