JDK-6325354 : HPROF: format=b problem with HAT: Thread 200000 not found for JNI local ref
  • Type: Bug
  • Component: tools
  • Sub-Component: hprof
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-09-16
  • Updated: 2010-04-02
  • Resolved: 2005-12-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0u7 b01Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
hprof format=b problem with HAT: Thread 200000 not found for JNI local ref

External customers still seeing problems:
still getting the error with 1.5.0_04-b05
Dump file created Mon Mar 24 16:50:44 EST 2769
java.io.IOException: Thread 200184 not found for JNI local ref
        at hat.parser.HprofReader.getThreadObjectFromSequence(HprofReader.java:577)
        at hat.parser.HprofReader.readHeapDump(HprofReader.java:379)
        at hat.parser.HprofReader.read(HprofReader.java:221)
        at hat.parser.Reader.readFile(Reader.java:90)
        at hat.Main.main(Main.java:149)

----

Investigation on Mustang (build 55 hopefully) has found a way to fix this permanently, need to go back and look at what can be done in Tiger.

Comments
EVALUATION As a thread is dumped, mark it so, when a local refers to a thread, make sure the thread was dumped, if not use the unknown thread serial number.
29-09-2005

SUGGESTED FIX Same change as Mustang, added in_heap_dump flag in tls table, added thread serial number as key for tls table so it can be searched on it, then added checks in hprof_site.c to make sure only threads dumped will be referenced. See the mustang diffs for hprof_tls.c, they are the same. ######### File: ./hprof_tls.h ######### (cd . && sccs diffs -C -w -s -b hprof_tls.h) ------- hprof_tls.h ------- *** /tmp/sccs.o5a4rK Wed Sep 28 18:08:51 2005 --- hprof_tls.h Wed Sep 28 17:37:51 2005 *************** *** 1,7 **** /* * %W% %E% * ! * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: --- 1,7 ---- /* * %W% %E% * ! * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: *************** *** 76,79 **** --- 76,85 ---- TraceIndex tls_get_trace(TlsIndex index, JNIEnv *env, int depth, jboolean skip_init); + void tls_set_in_heap_dump(TlsIndex index, jint in_heap_dump); + jint tls_get_in_heap_dump(TlsIndex index); + void tls_clear_in_heap_dump(void); + + TlsIndex tls_find(SerialNumber thread_serial_num); + #endif ######### File: ./hprof_site.c ######### (cd . && sccs diffs -C -w -s -b hprof_site.c) ------- hprof_site.c ------- *** /tmp/sccs.D1aqpK Wed Sep 28 18:08:51 2005 --- hprof_site.c Wed Sep 28 17:53:23 2005 *************** *** 342,347 **** --- 342,348 ---- SerialNumber thread_serial_num; SerialNumber trace_serial_num; TraceIndex trace_index; + TlsIndex tls_index; if ( (*tag_ptr) != (jlong)0 ) { setup_tag_on_root(tag_ptr, class_tag, size, 0, *************** *** 364,369 **** --- 365,375 ---- &object_index, &object_site_index); trace_index = gdata->system_trace_index; } + /* Get tls_index and set in_heap_dump, if we find it. */ + tls_index = tls_find(thread_serial_num); + if ( tls_index != 0 ) { + tls_set_in_heap_dump(tls_index, 1); + } trace_serial_num = trace_get_serial_number(trace_index); /* Issue thread object (must be before thread root) */ io_heap_root_thread_object(object_index, *************** *** 389,394 **** --- 395,415 ---- return JVMTI_ITERATION_CONTINUE; } + static SerialNumber + checkThreadSerialNumber(SerialNumber thread_serial_num) + { + TlsIndex tls_index; + + if ( thread_serial_num == gdata->unknown_thread_serial_num ) { + return thread_serial_num; + } + tls_index = tls_find(thread_serial_num); + if ( tls_index != 0 && tls_get_in_heap_dump(tls_index) != 0 ) { + return thread_serial_num; + } + return gdata->unknown_thread_serial_num; + } + /* JVMTI callback function. */ static jvmtiIterationControl JNICALL stack_object(jvmtiHeapRootKind root_kind, *************** *** 408,413 **** --- 429,435 ---- if ( (*tag_ptr) != (jlong)0 ) { object_index = tag_extract(*tag_ptr); thread_serial_num = object_get_thread_serial_number(object_index); + thread_serial_num = checkThreadSerialNumber(thread_serial_num); } else { SiteIndex site_index; *************** *** 419,424 **** --- 441,447 ---- thread_object_index = tag_extract(thread_tag); thread_serial_num = object_get_thread_serial_number(thread_object_index); + thread_serial_num = checkThreadSerialNumber(thread_serial_num); } else { thread_serial_num = gdata->unknown_thread_serial_num; } *************** *** 697,702 **** --- 720,728 ---- /* Remove class dumped status, all classes must be dumped */ class_all_status_remove(CLASS_DUMPED); + /* Clear in_heap_dump flag */ + tls_clear_in_heap_dump(); + /* Dump the last thread traces and get the lists back we need */ tls_dump_traces(env);
29-09-2005