mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
7190089: NMT ON: NMT failed assertion on thread's stack base address
Solaris only, record stack info to NMT after stack size adjustment was made for primordial threads Reviewed-by: kvn, acorn, coleenp
This commit is contained in:
parent
e91b6584eb
commit
afd497eecc
11 changed files with 30 additions and 17 deletions
|
@ -1488,11 +1488,11 @@ void _handle_uncaught_cxx_exception() {
|
||||||
|
|
||||||
|
|
||||||
// First crack at OS-specific initialization, from inside the new thread.
|
// First crack at OS-specific initialization, from inside the new thread.
|
||||||
void os::initialize_thread() {
|
void os::initialize_thread(Thread* thr) {
|
||||||
int r = thr_main() ;
|
int r = thr_main() ;
|
||||||
guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
|
guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
|
||||||
if (r) {
|
if (r) {
|
||||||
JavaThread* jt = (JavaThread *)Thread::current();
|
JavaThread* jt = (JavaThread *)thr;
|
||||||
assert(jt != NULL,"Sanity check");
|
assert(jt != NULL,"Sanity check");
|
||||||
size_t stack_size;
|
size_t stack_size;
|
||||||
address base = jt->stack_base();
|
address base = jt->stack_base();
|
||||||
|
|
|
@ -297,7 +297,7 @@ char* os::non_memory_address_word() {
|
||||||
return (char*) -1;
|
return (char*) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::initialize_thread() {
|
void os::initialize_thread(Thread* thr) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ char* os::non_memory_address_word() {
|
||||||
#endif // SPARC
|
#endif // SPARC
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::initialize_thread() {
|
void os::initialize_thread(Thread* thr) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ char* os::non_memory_address_word() {
|
||||||
return (char*) 0;
|
return (char*) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::initialize_thread() {}
|
void os::initialize_thread(Thread* thr) {}
|
||||||
|
|
||||||
void os::print_context(outputStream *st, void *context) {
|
void os::print_context(outputStream *st, void *context) {
|
||||||
if (context == NULL) return;
|
if (context == NULL) return;
|
||||||
|
|
|
@ -114,7 +114,7 @@ char* os::non_memory_address_word() {
|
||||||
return (char*) -1;
|
return (char*) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::initialize_thread() {
|
void os::initialize_thread(Thread* thr) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ char* os::non_memory_address_word() {
|
||||||
#endif // SPARC
|
#endif // SPARC
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::initialize_thread() {
|
void os::initialize_thread(Thread * thr){
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ bool os::register_code_area(char *low, char *high) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::initialize_thread() {
|
void os::initialize_thread(Thread* thr) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ class os: AllStatic {
|
||||||
static void pd_start_thread(Thread* thread);
|
static void pd_start_thread(Thread* thread);
|
||||||
static void start_thread(Thread* thread);
|
static void start_thread(Thread* thread);
|
||||||
|
|
||||||
static void initialize_thread();
|
static void initialize_thread(Thread* thr);
|
||||||
static void free_thread(OSThread* osthread);
|
static void free_thread(OSThread* osthread);
|
||||||
|
|
||||||
// thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit
|
// thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit
|
||||||
|
|
|
@ -308,20 +308,26 @@ void Thread::initialize_thread_local_storage() {
|
||||||
|
|
||||||
// initialize structure dependent on thread local storage
|
// initialize structure dependent on thread local storage
|
||||||
ThreadLocalStorage::set_thread(this);
|
ThreadLocalStorage::set_thread(this);
|
||||||
|
|
||||||
// set up any platform-specific state.
|
|
||||||
os::initialize_thread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::record_stack_base_and_size() {
|
void Thread::record_stack_base_and_size() {
|
||||||
set_stack_base(os::current_stack_base());
|
set_stack_base(os::current_stack_base());
|
||||||
set_stack_size(os::current_stack_size());
|
set_stack_size(os::current_stack_size());
|
||||||
|
// CR 7190089: on Solaris, primordial thread's stack is adjusted
|
||||||
|
// in initialize_thread(). Without the adjustment, stack size is
|
||||||
|
// incorrect if stack is set to unlimited (ulimit -s unlimited).
|
||||||
|
// So far, only Solaris has real implementation of initialize_thread().
|
||||||
|
//
|
||||||
|
// set up any platform-specific state.
|
||||||
|
os::initialize_thread(this);
|
||||||
|
|
||||||
// record thread's native stack, stack grows downward
|
// record thread's native stack, stack grows downward
|
||||||
address low_stack_addr = stack_base() - stack_size();
|
if (MemTracker::is_on()) {
|
||||||
MemTracker::record_thread_stack(low_stack_addr, stack_size(), this,
|
address stack_low_addr = stack_base() - stack_size();
|
||||||
|
MemTracker::record_thread_stack(stack_low_addr, stack_size(), this,
|
||||||
CURRENT_PC);
|
CURRENT_PC);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread::~Thread() {
|
Thread::~Thread() {
|
||||||
|
|
|
@ -341,6 +341,7 @@ void MemTracker::release_thread_recorder(MemRecorder* rec) {
|
||||||
*/
|
*/
|
||||||
void MemTracker::create_memory_record(address addr, MEMFLAGS flags,
|
void MemTracker::create_memory_record(address addr, MEMFLAGS flags,
|
||||||
size_t size, address pc, Thread* thread) {
|
size_t size, address pc, Thread* thread) {
|
||||||
|
assert(addr != NULL, "Sanity check");
|
||||||
if (!shutdown_in_progress()) {
|
if (!shutdown_in_progress()) {
|
||||||
// single thread, we just write records direct to global recorder,'
|
// single thread, we just write records direct to global recorder,'
|
||||||
// with any lock
|
// with any lock
|
||||||
|
|
|
@ -185,6 +185,7 @@ class MemTracker : AllStatic {
|
||||||
static inline void record_malloc(address addr, size_t size, MEMFLAGS flags,
|
static inline void record_malloc(address addr, size_t size, MEMFLAGS flags,
|
||||||
address pc = 0, Thread* thread = NULL) {
|
address pc = 0, Thread* thread = NULL) {
|
||||||
if (NMT_CAN_TRACK(flags)) {
|
if (NMT_CAN_TRACK(flags)) {
|
||||||
|
assert(size > 0, "Sanity check");
|
||||||
create_memory_record(addr, (flags|MemPointerRecord::malloc_tag()), size, pc, thread);
|
create_memory_record(addr, (flags|MemPointerRecord::malloc_tag()), size, pc, thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +199,7 @@ class MemTracker : AllStatic {
|
||||||
static inline void record_realloc(address old_addr, address new_addr, size_t size,
|
static inline void record_realloc(address old_addr, address new_addr, size_t size,
|
||||||
MEMFLAGS flags, address pc = 0, Thread* thread = NULL) {
|
MEMFLAGS flags, address pc = 0, Thread* thread = NULL) {
|
||||||
if (is_on()) {
|
if (is_on()) {
|
||||||
|
assert(size > 0, "Sanity check");
|
||||||
record_free(old_addr, flags, thread);
|
record_free(old_addr, flags, thread);
|
||||||
record_malloc(new_addr, size, flags, pc, thread);
|
record_malloc(new_addr, size, flags, pc, thread);
|
||||||
}
|
}
|
||||||
|
@ -208,6 +210,7 @@ class MemTracker : AllStatic {
|
||||||
// we add a positive offset to arena address, so we can have arena size record
|
// we add a positive offset to arena address, so we can have arena size record
|
||||||
// sorted after arena record
|
// sorted after arena record
|
||||||
if (is_on() && !UseMallocOnly) {
|
if (is_on() && !UseMallocOnly) {
|
||||||
|
assert(addr != NULL, "Sanity check");
|
||||||
create_memory_record((addr + sizeof(void*)), MemPointerRecord::arena_size_tag(), size,
|
create_memory_record((addr + sizeof(void*)), MemPointerRecord::arena_size_tag(), size,
|
||||||
0, NULL);
|
0, NULL);
|
||||||
}
|
}
|
||||||
|
@ -217,7 +220,7 @@ class MemTracker : AllStatic {
|
||||||
static inline void record_virtual_memory_reserve(address addr, size_t size,
|
static inline void record_virtual_memory_reserve(address addr, size_t size,
|
||||||
address pc = 0, Thread* thread = NULL) {
|
address pc = 0, Thread* thread = NULL) {
|
||||||
if (is_on()) {
|
if (is_on()) {
|
||||||
assert(size > 0, "reserve szero size");
|
assert(size > 0, "Sanity check");
|
||||||
create_memory_record(addr, MemPointerRecord::virtual_memory_reserve_tag(),
|
create_memory_record(addr, MemPointerRecord::virtual_memory_reserve_tag(),
|
||||||
size, pc, thread);
|
size, pc, thread);
|
||||||
}
|
}
|
||||||
|
@ -248,6 +251,7 @@ class MemTracker : AllStatic {
|
||||||
static inline void record_virtual_memory_commit(address addr, size_t size,
|
static inline void record_virtual_memory_commit(address addr, size_t size,
|
||||||
address pc = 0, Thread* thread = NULL) {
|
address pc = 0, Thread* thread = NULL) {
|
||||||
if (is_on()) {
|
if (is_on()) {
|
||||||
|
assert(size > 0, "Sanity check");
|
||||||
create_memory_record(addr, MemPointerRecord::virtual_memory_commit_tag(),
|
create_memory_record(addr, MemPointerRecord::virtual_memory_commit_tag(),
|
||||||
size, DEBUG_CALLER_PC, thread);
|
size, DEBUG_CALLER_PC, thread);
|
||||||
}
|
}
|
||||||
|
@ -257,6 +261,7 @@ class MemTracker : AllStatic {
|
||||||
static inline void record_virtual_memory_uncommit(address addr, size_t size,
|
static inline void record_virtual_memory_uncommit(address addr, size_t size,
|
||||||
Thread* thread = NULL) {
|
Thread* thread = NULL) {
|
||||||
if (is_on()) {
|
if (is_on()) {
|
||||||
|
assert(size > 0, "Sanity check");
|
||||||
create_memory_record(addr, MemPointerRecord::virtual_memory_uncommit_tag(),
|
create_memory_record(addr, MemPointerRecord::virtual_memory_uncommit_tag(),
|
||||||
size, DEBUG_CALLER_PC, thread);
|
size, DEBUG_CALLER_PC, thread);
|
||||||
}
|
}
|
||||||
|
@ -266,6 +271,7 @@ class MemTracker : AllStatic {
|
||||||
static inline void record_virtual_memory_release(address addr, size_t size,
|
static inline void record_virtual_memory_release(address addr, size_t size,
|
||||||
Thread* thread = NULL) {
|
Thread* thread = NULL) {
|
||||||
if (is_on()) {
|
if (is_on()) {
|
||||||
|
assert(size > 0, "Sanity check");
|
||||||
create_memory_record(addr, MemPointerRecord::virtual_memory_release_tag(),
|
create_memory_record(addr, MemPointerRecord::virtual_memory_release_tag(),
|
||||||
size, DEBUG_CALLER_PC, thread);
|
size, DEBUG_CALLER_PC, thread);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue