--- old/src/share/vm/gc/shared/vmGCOperations.cpp 2016-03-07 14:48:49.818985814 -0500 +++ new/src/share/vm/gc/shared/vmGCOperations.cpp 2016-03-07 14:48:48.974937498 -0500 @@ -172,11 +172,15 @@ void VM_GenCollectForAllocation::doit() { SvcGCMarker sgcm(SvcGCMarker::MINOR); + Threads::verify(); + GenCollectedHeap* gch = GenCollectedHeap::heap(); GCCauseSetter gccs(gch, _gc_cause); _result = gch->satisfy_failed_allocation(_word_size, _tlab); assert(gch->is_in_reserved_or_null(_result), "result not in heap"); + Threads::verify(); + if (_result == NULL && GCLocker::is_active_and_needs_gc()) { set_gc_locked(); } @@ -185,9 +189,15 @@ void VM_GenCollectFull::doit() { SvcGCMarker sgcm(SvcGCMarker::FULL); + assert_at_safepoint(true /* should_be_vm_thread */); + Threads::verify(); + GenCollectedHeap* gch = GenCollectedHeap::heap(); GCCauseSetter gccs(gch, _gc_cause); gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_generation); + + Threads::verify(); + } VM_CollectForMetadataAllocation::VM_CollectForMetadataAllocation(ClassLoaderData* loader_data, @@ -237,6 +247,10 @@ CollectedHeap* heap = Universe::heap(); GCCauseSetter gccs(heap, _gc_cause); + assert_at_safepoint(true /* should_be_vm_thread */); + + Threads::verify(); + // Check again if the space is available. Another thread // may have similarly failed a metadata allocation and induced // a GC that freed space for the allocation. @@ -259,6 +273,10 @@ // Don't clear the soft refs yet. heap->collect_as_vm_thread(GCCause::_metadata_GC_threshold); + + + Threads::verify(); + // After a GC try to allocate without expanding. Could fail // and expansion will be tried below. _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype); @@ -281,8 +299,14 @@ // behavior is similar to the last-ditch collection done for perm // gen when it was full and a collection for failed allocation // did not free perm gen space. + + Threads::verify(); + heap->collect_as_vm_thread(GCCause::_last_ditch_collection); _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype); + + Threads::verify(); + if (_result != NULL) { return; } --- old/src/share/vm/runtime/frame.cpp 2016-03-07 14:48:52.403133734 -0500 +++ new/src/share/vm/runtime/frame.cpp 2016-03-07 14:48:51.567085875 -0500 @@ -719,6 +719,17 @@ if (offset < _max_locals) { addr = (oop*) _fr->interpreter_frame_local_at(offset); assert((intptr_t*)addr >= _fr->sp(), "must be inside the frame"); + + if (*addr != NULL) { + if (!Universe::heap()->is_in_reserved(*addr)) { + char errMsg[256]; + sprintf((char*)&errMsg, "BAD LOCALS OOP " PTR_FORMAT " at " PTR_FORMAT " offset %x, local count %x, TOS " PTR_FORMAT , + p2i(*addr), p2i(addr), offset, _max_locals, p2i(_fr->interpreter_frame_tos_address())); + report_vm_error(__FILE__, __LINE__, (const char*)&errMsg); + BREAKPOINT; + } + } + _f->do_oop(addr); } else { addr = (oop*) _fr->interpreter_frame_expression_stack_at((offset - _max_locals)); @@ -731,7 +742,35 @@ in_stack = (intptr_t*)addr >= _fr->interpreter_frame_tos_address(); } if (in_stack) { - _f->do_oop(addr); + if (*addr != NULL) { + if (!Universe::heap()->is_in_reserved(*addr)) { + + oop* slot = addr; + FILE * stackdump; + stackdump = fopen ("stackdump.txt", "w+"); + + char buf[512]; + Method* m = _fr->interpreter_frame_method(); + if (m != NULL) { + m->name_and_sig_as_C_string((char*)&buf, 512); + fprintf(stackdump, "*** method %s (%d)\n", (char*)&buf, _fr->interpreter_frame_bci()); + } + + for (int z = 0; z < 200; z++) { + fprintf(stackdump, ">>>>>>>>>>>>>> %lx: %lx \n", p2i(slot), p2i(*slot)); + slot--; + } + + char errMsg[256]; + sprintf((char*)&errMsg, "BAD STACK OOP " PTR_FORMAT " at " PTR_FORMAT " offset %x, local count %x, TOS " PTR_FORMAT , + p2i(*addr), p2i(addr), offset, _max_locals, p2i(_fr->interpreter_frame_tos_address())); + report_vm_error(__FILE__, __LINE__, (const char*)&errMsg); + BREAKPOINT; + } + + } + + _f->do_oop(addr); } } } @@ -756,6 +795,17 @@ void oop_offset_do() { oop* addr; addr = (oop*)_fr->interpreter_frame_tos_at(_offset); + + if (*addr != NULL) { + if (!Universe::heap()->is_in_reserved(*addr)) { + char errMsg[256]; + sprintf((char*)&errMsg, "BAD ARGUMENT OOP " PTR_FORMAT " at " PTR_FORMAT " offset %x, TOS " PTR_FORMAT , + p2i(*addr), p2i(addr), _offset, p2i( _fr->interpreter_frame_tos_address())); + report_vm_error(__FILE__, __LINE__, (const char*)&errMsg); + BREAKPOINT; + } + } + _f->do_oop(addr); } --- old/src/share/vm/runtime/thread.cpp 2016-03-07 14:48:55.155291272 -0500 +++ new/src/share/vm/runtime/thread.cpp 2016-03-07 14:48:54.315243187 -0500 @@ -2764,7 +2764,8 @@ void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { // Verify that the deferred card marks have been flushed. - assert(deferred_card_mark().is_empty(), "Should be empty during GC"); + // TEMPORARILY COMMENT ASSERT OUT: NOT VALID WITH TEMP HEAP VERIFICATION CALLS + // assert(deferred_card_mark().is_empty(), "Should be empty during GC"); // The ThreadProfiler oops_do is done from FlatProfiler::oops_do // since there may be more than one thread using each ThreadProfiler.