Skip to content

Commit fb9a29d

Browse files
committed
8305414: gtest/NMTGtests.java is failing various sub-tests
Reviewed-by: rkennke, adinn
1 parent e846a1d commit fb9a29d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/hotspot/share/services/mallocTracker.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ void MallocTracker::deaccount(MallocHeader::FreeInfo free_info) {
194194

195195
// Given a pointer, look for the containing malloc block.
196196
// Print the block. Note that since there is very low risk of memory looking
197-
// accidentally like a valid malloc block header (canaries and all) this is not
198-
// totally failproof. Only use this during debugging or when you can afford
199-
// signals popping up, e.g. when writing an hs_err file.
197+
// accidentally like a valid malloc block header (canaries and all) so this is not
198+
// totally failproof and may give a wrong answer. It is safe in that it will never
199+
// crash, even when encountering unmapped memory.
200200
bool MallocTracker::print_pointer_information(const void* p, outputStream* st) {
201201
assert(MemTracker::enabled(), "NMT not enabled");
202202

@@ -215,7 +215,7 @@ bool MallocTracker::print_pointer_information(const void* p, outputStream* st) {
215215
for (; here >= end; here -= smallest_possible_alignment) {
216216
if (!os::is_readable_pointer(here)) {
217217
// Probably OOB, give up
218-
return false;
218+
break;
219219
}
220220
const MallocHeader* const candidate = (const MallocHeader*)here;
221221
if (!candidate->looks_valid()) {

test/hotspot/gtest/nmt/test_nmt_locationprinting.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void test_pointer(const void* p, bool expected_return_code, const char* e
4747

4848
static void test_for_live_c_heap_block(size_t sz, ssize_t offset) {
4949
char* c = NEW_C_HEAP_ARRAY(char, sz, mtTest);
50-
LOG_HERE("C-block starts " PTR_FORMAT ", size " SIZE_FORMAT ".", p2i(c), offset);
50+
LOG_HERE("C-block starts " PTR_FORMAT ", size " SIZE_FORMAT ".", p2i(c), sz);
5151
memset(c, 0, sz);
5252
if (MemTracker::enabled()) {
5353
const char* expected_string = "into live malloced block";
@@ -69,7 +69,7 @@ static void test_for_dead_c_heap_block(size_t sz, ssize_t offset) {
6969
return;
7070
}
7171
char* c = NEW_C_HEAP_ARRAY(char, sz, mtTest);
72-
LOG_HERE("C-block starts " PTR_FORMAT ", size " SIZE_FORMAT ".", p2i(c), offset);
72+
LOG_HERE("C-block starts " PTR_FORMAT ", size " SIZE_FORMAT ".", p2i(c), sz);
7373
memset(c, 0, sz);
7474
// We cannot just free the allocation to try dead block printing, since the memory
7575
// may be immediately reused by concurrent code. Instead, we mark the block as dead
@@ -99,13 +99,13 @@ TEST_VM(NMT, location_printing_cheap_live_6) { test_for_live_c_heap_block(4, 0);
9999
TEST_VM(NMT, location_printing_cheap_live_7) { test_for_live_c_heap_block(4, 4); } // just outside a very small block
100100

101101
#ifdef LINUX
102-
TEST_VM(NMT, DISABLED_location_printing_cheap_dead_1) { test_for_dead_c_heap_block(2 * K, 0); } // start of payload
103-
TEST_VM(NMT, DISABLED_location_printing_cheap_dead_2) { test_for_dead_c_heap_block(2 * K, -7); } // into header
104-
TEST_VM(NMT, DISABLED_location_printing_cheap_dead_3) { test_for_dead_c_heap_block(2 * K, K + 1); } // into payload
105-
TEST_VM(NMT, DISABLED_location_printing_cheap_dead_4) { test_for_dead_c_heap_block(2 * K, K + 2); } // into payload (check for even/odd errors)
102+
TEST_VM(NMT, location_printing_cheap_dead_1) { test_for_dead_c_heap_block(2 * K, 0); } // start of payload
103+
TEST_VM(NMT, location_printing_cheap_dead_2) { test_for_dead_c_heap_block(2 * K, -7); } // into header
104+
TEST_VM(NMT, location_printing_cheap_dead_3) { test_for_dead_c_heap_block(2 * K, K + 1); } // into payload
105+
TEST_VM(NMT, location_printing_cheap_dead_4) { test_for_dead_c_heap_block(2 * K, K + 2); } // into payload (check for even/odd errors)
106106
TEST_VM(NMT, location_printing_cheap_dead_5) { test_for_dead_c_heap_block(2 * K + 1, 2 * K + 2); } // just outside payload
107-
TEST_VM(NMT, DISABLED_location_printing_cheap_dead_6) { test_for_dead_c_heap_block(4, 0); } // into a very small block
108-
TEST_VM(NMT, DISABLED_location_printing_cheap_dead_7) { test_for_dead_c_heap_block(4, 4); } // just outside a very small block
107+
TEST_VM(NMT, location_printing_cheap_dead_6) { test_for_dead_c_heap_block(4, 0); } // into a very small block
108+
TEST_VM(NMT, location_printing_cheap_dead_7) { test_for_dead_c_heap_block(4, 4); } // just outside a very small block
109109
#endif
110110

111111
static void test_for_mmap(size_t sz, ssize_t offset) {

0 commit comments

Comments
 (0)