提交 64f18b82 编写于 作者: Z zgu

7190089: NMT ON: NMT failed assertion on thread's stack base address

Summary: Solaris only, record stack info to NMT after stack size adjustment was made for primordial threads
Reviewed-by: kvn, acorn, coleenp
上级 65a64fdc
......@@ -1488,11 +1488,11 @@ void _handle_uncaught_cxx_exception() {
// 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() ;
guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
if (r) {
JavaThread* jt = (JavaThread *)Thread::current();
JavaThread* jt = (JavaThread *)thr;
assert(jt != NULL,"Sanity check");
size_t stack_size;
address base = jt->stack_base();
......
......@@ -297,7 +297,7 @@ char* os::non_memory_address_word() {
return (char*) -1;
}
void os::initialize_thread() {
void os::initialize_thread(Thread* thr) {
// Nothing to do.
}
......
......@@ -103,7 +103,7 @@ char* os::non_memory_address_word() {
#endif // SPARC
}
void os::initialize_thread() {
void os::initialize_thread(Thread* thr) {
// Nothing to do.
}
......
......@@ -225,7 +225,7 @@ char* os::non_memory_address_word() {
return (char*) 0;
}
void os::initialize_thread() {}
void os::initialize_thread(Thread* thr) {}
void os::print_context(outputStream *st, void *context) {
if (context == NULL) return;
......
......@@ -114,7 +114,7 @@ char* os::non_memory_address_word() {
return (char*) -1;
}
void os::initialize_thread() {
void os::initialize_thread(Thread* thr) {
// Nothing to do.
}
......
......@@ -98,7 +98,7 @@ char* os::non_memory_address_word() {
#endif // SPARC
}
void os::initialize_thread() {
void os::initialize_thread(Thread * thr){
// Nothing to do.
}
......
......@@ -219,7 +219,7 @@ bool os::register_code_area(char *low, char *high) {
return true;
}
void os::initialize_thread() {
void os::initialize_thread(Thread* thr) {
// Nothing to do.
}
......
......@@ -387,7 +387,7 @@ class os: AllStatic {
static void pd_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);
// thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit
......
......@@ -308,19 +308,25 @@ void Thread::initialize_thread_local_storage() {
// initialize structure dependent on thread local storage
ThreadLocalStorage::set_thread(this);
// set up any platform-specific state.
os::initialize_thread();
}
void Thread::record_stack_base_and_size() {
set_stack_base(os::current_stack_base());
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
address low_stack_addr = stack_base() - stack_size();
MemTracker::record_thread_stack(low_stack_addr, stack_size(), this,
if (MemTracker::is_on()) {
address stack_low_addr = stack_base() - stack_size();
MemTracker::record_thread_stack(stack_low_addr, stack_size(), this,
CURRENT_PC);
}
}
......
......@@ -341,6 +341,7 @@ void MemTracker::release_thread_recorder(MemRecorder* rec) {
*/
void MemTracker::create_memory_record(address addr, MEMFLAGS flags,
size_t size, address pc, Thread* thread) {
assert(addr != NULL, "Sanity check");
if (!shutdown_in_progress()) {
// single thread, we just write records direct to global recorder,'
// with any lock
......
......@@ -185,6 +185,7 @@ class MemTracker : AllStatic {
static inline void record_malloc(address addr, size_t size, MEMFLAGS flags,
address pc = 0, Thread* thread = NULL) {
if (NMT_CAN_TRACK(flags)) {
assert(size > 0, "Sanity check");
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,
MEMFLAGS flags, address pc = 0, Thread* thread = NULL) {
if (is_on()) {
assert(size > 0, "Sanity check");
record_free(old_addr, flags, 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
// sorted after arena record
if (is_on() && !UseMallocOnly) {
assert(addr != NULL, "Sanity check");
create_memory_record((addr + sizeof(void*)), MemPointerRecord::arena_size_tag(), size,
0, NULL);
}
......@@ -217,7 +220,7 @@ class MemTracker : AllStatic {
static inline void record_virtual_memory_reserve(address addr, size_t size,
address pc = 0, Thread* thread = NULL) {
if (is_on()) {
assert(size > 0, "reserve szero size");
assert(size > 0, "Sanity check");
create_memory_record(addr, MemPointerRecord::virtual_memory_reserve_tag(),
size, pc, thread);
}
......@@ -248,6 +251,7 @@ class MemTracker : AllStatic {
static inline void record_virtual_memory_commit(address addr, size_t size,
address pc = 0, Thread* thread = NULL) {
if (is_on()) {
assert(size > 0, "Sanity check");
create_memory_record(addr, MemPointerRecord::virtual_memory_commit_tag(),
size, DEBUG_CALLER_PC, thread);
}
......@@ -257,6 +261,7 @@ class MemTracker : AllStatic {
static inline void record_virtual_memory_uncommit(address addr, size_t size,
Thread* thread = NULL) {
if (is_on()) {
assert(size > 0, "Sanity check");
create_memory_record(addr, MemPointerRecord::virtual_memory_uncommit_tag(),
size, DEBUG_CALLER_PC, thread);
}
......@@ -266,6 +271,7 @@ class MemTracker : AllStatic {
static inline void record_virtual_memory_release(address addr, size_t size,
Thread* thread = NULL) {
if (is_on()) {
assert(size > 0, "Sanity check");
create_memory_record(addr, MemPointerRecord::virtual_memory_release_tag(),
size, DEBUG_CALLER_PC, thread);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册