mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
8252921: NMT overwrite memory type for region assert when building dynamic archive
Reviewed-by: minqi, iklam, dholmes
This commit is contained in:
parent
0c287de4f6
commit
8c02bdbf13
3 changed files with 12 additions and 14 deletions
|
@ -363,6 +363,10 @@ void Thread::record_stack_base_and_size() {
|
||||||
void Thread::register_thread_stack_with_NMT() {
|
void Thread::register_thread_stack_with_NMT() {
|
||||||
MemTracker::record_thread_stack(stack_end(), stack_size());
|
MemTracker::record_thread_stack(stack_end(), stack_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Thread::unregister_thread_stack_with_NMT() {
|
||||||
|
MemTracker::release_thread_stack(stack_end(), stack_size());
|
||||||
|
}
|
||||||
#endif // INCLUDE_NMT
|
#endif // INCLUDE_NMT
|
||||||
|
|
||||||
void Thread::call_run() {
|
void Thread::call_run() {
|
||||||
|
@ -428,19 +432,6 @@ Thread::~Thread() {
|
||||||
barrier_set->on_thread_destroy(this);
|
barrier_set->on_thread_destroy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stack_base can be NULL if the thread is never started or exited before
|
|
||||||
// record_stack_base_and_size called. Although, we would like to ensure
|
|
||||||
// that all started threads do call record_stack_base_and_size(), there is
|
|
||||||
// not proper way to enforce that.
|
|
||||||
#if INCLUDE_NMT
|
|
||||||
if (_stack_base != NULL) {
|
|
||||||
MemTracker::release_thread_stack(stack_end(), stack_size());
|
|
||||||
#ifdef ASSERT
|
|
||||||
set_stack_base(NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif // INCLUDE_NMT
|
|
||||||
|
|
||||||
// deallocate data structures
|
// deallocate data structures
|
||||||
delete resource_area();
|
delete resource_area();
|
||||||
// since the handle marks are using the handle area, we have to deallocated the root
|
// since the handle marks are using the handle area, we have to deallocated the root
|
||||||
|
@ -1340,6 +1331,7 @@ void NonJavaThread::pre_run() {
|
||||||
void NonJavaThread::post_run() {
|
void NonJavaThread::post_run() {
|
||||||
JFR_ONLY(Jfr::on_thread_exit(this);)
|
JFR_ONLY(Jfr::on_thread_exit(this);)
|
||||||
remove_from_the_list();
|
remove_from_the_list();
|
||||||
|
unregister_thread_stack_with_NMT();
|
||||||
// Ensure thread-local-storage is cleared before termination.
|
// Ensure thread-local-storage is cleared before termination.
|
||||||
Thread::clear_thread_current();
|
Thread::clear_thread_current();
|
||||||
}
|
}
|
||||||
|
@ -2013,6 +2005,7 @@ void JavaThread::thread_main_inner() {
|
||||||
// Shared teardown for all JavaThreads
|
// Shared teardown for all JavaThreads
|
||||||
void JavaThread::post_run() {
|
void JavaThread::post_run() {
|
||||||
this->exit(false);
|
this->exit(false);
|
||||||
|
this->unregister_thread_stack_with_NMT();
|
||||||
// Defer deletion to here to ensure 'this' is still referenceable in call_run
|
// Defer deletion to here to ensure 'this' is still referenceable in call_run
|
||||||
// for any shared tear-down.
|
// for any shared tear-down.
|
||||||
this->smr_delete();
|
this->smr_delete();
|
||||||
|
|
|
@ -766,6 +766,7 @@ protected:
|
||||||
address stack_end() const { return stack_base() - stack_size(); }
|
address stack_end() const { return stack_base() - stack_size(); }
|
||||||
void record_stack_base_and_size();
|
void record_stack_base_and_size();
|
||||||
void register_thread_stack_with_NMT() NOT_NMT_RETURN;
|
void register_thread_stack_with_NMT() NOT_NMT_RETURN;
|
||||||
|
void unregister_thread_stack_with_NMT() NOT_NMT_RETURN;
|
||||||
|
|
||||||
int lgrp_id() const { return _lgrp_id; }
|
int lgrp_id() const { return _lgrp_id; }
|
||||||
void set_lgrp_id(int value) { _lgrp_id = value; }
|
void set_lgrp_id(int value) { _lgrp_id = value; }
|
||||||
|
|
|
@ -347,7 +347,11 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size,
|
||||||
VirtualMemorySummary::record_reserved_memory(size, flag);
|
VirtualMemorySummary::record_reserved_memory(size, flag);
|
||||||
return _reserved_regions->add(rgn) != NULL;
|
return _reserved_regions->add(rgn) != NULL;
|
||||||
} else {
|
} else {
|
||||||
if (reserved_rgn->same_region(base_addr, size)) {
|
// Deal with recursive reservation
|
||||||
|
// os::reserve_memory() -> pd_reserve_memory() -> os::reserve_memory()
|
||||||
|
// See JDK-8198226.
|
||||||
|
if (reserved_rgn->same_region(base_addr, size) &&
|
||||||
|
(reserved_rgn->flag() == flag || reserved_rgn->flag() == mtNone)) {
|
||||||
reserved_rgn->set_call_stack(stack);
|
reserved_rgn->set_call_stack(stack);
|
||||||
reserved_rgn->set_flag(flag);
|
reserved_rgn->set_flag(flag);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue