JDK-6444034 : Starting JVM from non-primordial thread breaks compatibility
  • Type: Enhancement
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-06-27
  • Updated: 2010-05-11
  • Resolved: 2006-11-06
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
Dynamic libraries can be loaded by the virtual machine at run time, but they are unloaded by the kernel when the application ends.

This means that static resources allocated by the DLL will be allocated in the current thread of the JVM at the point when the library is loaded, but disposed in the primordial thread when the kernel cleans up.

Please supply a parameter to have the launcher create the JVM in the primordial thread to maintain compatibility, or somehow free the dynamically loaded libraries in the thread in which they were loaded.

JUSTIFICATION :
Deallocating resources in another thread than the one in which they were created is potentially dangerous and can cause corruption and crashes.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The destructors of static objects allocated in a DLL loaded on run time must be called from the same thread as the one which called their constructors.
ACTUAL -
The destructors are called from a different thread than the constructors.

CUSTOMER SUBMITTED WORKAROUND :
By not using the standard Java launcher, but instead writing your own, you can force the JVM to be loaded in the primordial thread.

Comments
EVALUATION We are trying to narrow down this issue. Sometimes these type of issues are not as strait forward as they appear. Identifying the cause and the subsequent fix can be difficult to difficult. In this instance there are only a few dlls that libjvm is directly dependent on, all the others are dynamically loaded through the VM, and the rest are user's JNI applications. So this could very well be a specific dll unloading issue. A test case would be very useful to correctly evaluate this CR. If you have a test case that can reproduce this please add it to the comments at: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6444034 or alternately, you can create a new Incident at http://bugs.sun.com/services/bugreport/index.jsp making sure to include the bug id (6444034) in the synopsis and the body of the Incident. -Sun's Java SE team
16-10-2006