JDK-5096167 : null class name crashes VM if ClassFileLoadHook is enabled
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,x86
  • Submitted: 2004-09-02
  • Updated: 2012-10-09
  • Resolved: 2004-09-24
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 JDK 6
5.0u1 01Fixed 6Fixed
Related Reports
Duplicate :  
Relates :  
Description
java.lang.ClassLoader.defineClass allows a null class name.
If the class name is null, a NULL handle is used in the implementation of the ClassFileLoadHook.  This NULL causes the VM to crash.

There is no work-around in the agent -- the crash occurs before the event handler is called.

Since both java.lang.instrument and the hprof demo tool use the ClassFileLoadHook they are both impacted by this.  

A known real-world occurrance of this is the xalan XML parser which generates classes on the fly and loads them with a null name.

The fix is trivial, simply the addition of a NULL check -- see suggested fix.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 FIXED IN: 1.5.0_01 INTEGRATED IN: 1.5.0_01
24-09-2004

EVALUATION Crash with no work-around which has a trivial fix. Must be fixed.
24-09-2004

WORK AROUND None.
24-09-2004

SUGGESTED FIX --- jvmtiExport.cpp Wed Sep 1 18:44:00 2004 *************** *** 211, 214 **** JvmtiClassFileLoadEventMark(JavaThread *thread, symbolHandle name, Handle class_loader, Handle prot_domain, KlassHandle *class_being_redefined) : JvmtiThreadEventMark(thread) { ! _class_name = name->as_utf8(); _jloader = (jobject)to_jobject(class_loader()); --- 211, 214 ---- JvmtiClassFileLoadEventMark(JavaThread *thread, symbolHandle name, Handle class_loader, Handle prot_domain, KlassHandle *class_being_redefined) : JvmtiThreadEventMark(thread) { ! _class_name = name() != NULL? name->as_utf8() : NULL; _jloader = (jobject)to_jobject(class_loader());
24-09-2004

PUBLIC COMMENTS java.lang.ClassLoader.defineClass allows a null class name. If the class name is null, a NULL handle is used in the implementation of the ClassFileLoadHook. This NULL causes the VM to crash. There is no work-around in the agent -- the crash occurs before the event handler is called.
24-09-2004