JDK-6358509 : HPROF: Loading twice is not properly handled. Misleading error message.
  • Type: Bug
  • Component: tools
  • Sub-Component: hprof
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-12-02
  • Updated: 2010-04-02
  • Resolved: 2005-12-17
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.
JDK 6
6 b65Fixed
Related Reports
Duplicate :  
Relates :  
Description
Generate a reasonable fatal error when the hprof agent is loaded twice.

Comments
SUGGESTED FIX ######### File: ./hprof.h ######### (cd . && sccs diffs -C -w -s -b hprof.h) ------- hprof.h ------- *** /tmp/sccs.2uaiPP Tue Dec 6 15:45:49 2005 --- hprof.h Tue Dec 6 15:26:04 2005 *************** *** 391,396 **** --- 391,399 ---- void * java_crw_demo_function; void * java_crw_demo_classname_function; + /* Indication that the agent has been loaded */ + jboolean isLoaded; + } GlobalData; /* This should be the only 'extern' in the library (not exported). */ ######### File: ./hprof_init.c ######### (cd . && sccs diffs -C -w -s -b hprof_init.c) ------- hprof_init.c ------- *** /tmp/sccs.hvaWPP Tue Dec 6 15:45:49 2005 --- hprof_init.c Tue Dec 6 15:45:45 2005 *************** *** 1937,1944 **** --- 1937,1952 ---- JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { + /* See if it's already loaded */ + if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) { + HPROF_ERROR(JNI_TRUE, "Cannot load this JVM TI agent twice, check your java command line for duplicate hprof options."); + return JNI_ERR; + } + gdata = get_gdata(); + gdata->isLoaded = JNI_TRUE; + error_setup(); LOG2("Agent_OnLoad", "gdata setup"); *************** *** 2052,2057 **** --- 2060,2067 ---- LOG("Agent_OnUnload"); + gdata->isLoaded = JNI_FALSE; + stack = gdata->object_free_stack; gdata->object_free_stack = NULL; if ( stack != NULL ) {
06-12-2005

EVALUATION Detect the agent being loaded twice, print reasonable error message.
06-12-2005