JDK-6431829 : Hotspot global static variable initialization should not call malloc
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-30
  • Updated: 2015-02-23
  • Resolved: 2015-02-23
Related Reports
Relates :  
Relates :  
Description
See comments for an example of what should be fixed.  Static variables initalized via calls to malloc can be problematic:

1. Affects restartability or repeated calls to CreateJavaVM / DestroyJavaVM from user JNI code.  Specifically, loading libjvm.so will allocate the storage, DestroyJavaVM will presumably deallocate it.  But a subsequent call to CreateJavaVM will NOT re-allocate the storage, probably causing access to uninitialized memory.

2. Makes it difficult for tracing malloc usage with mtrace.  Mtracing requires an explicit call to mtrace() in user code.  It is difficult for user code to get in front of the calls to malloc that are made to initialize static variables.  In this case mtrace can miss allocations and erroneously report nonexistent memory leak issues.

Comments
This is not something that is practical to change, and there is currently no real world scenario where this is a problem. Closing as WNF
23-02-2015

EVALUATION Please see comments.
10-11-2006