Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 275321 - JVM crash on attach in heapprof enabled mode
Summary: JVM crash on attach in heapprof enabled mode
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: TPTP (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: ---   Edit
Assignee: Chengrui Deng CLA
QA Contact: Kathy Chan CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-07 11:25 EDT by Jonathan West CLA
Modified: 2016-05-05 10:42 EDT (History)
6 users (show)

See Also:


Attachments
Add null pointer check to avoid JVM crash on attach in heapprof (972 bytes, patch)
2009-05-13 02:59 EDT, Chengrui Deng CLA
chengrui.deng: review?
Details | Diff
Profiler binary files for testing on WindowsXP (1.04 MB, application/x-zip-compressed)
2009-05-13 03:05 EDT, Chengrui Deng CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan West CLA 2009-05-07 11:25:33 EDT
Removing all filters and attaching to HeapJniCarTest in HeapProf enabled mode causes JVM crash. Sun JVM/Windows.

See comments #5 through #12 of bug 270767 for full description.
Comment 1 Kathy Chan CLA 2009-05-07 14:56:13 EDT
Chengrui or Yunan,

Please take a look at this problem for TPTP 4.6.
Comment 2 Jonathan West CLA 2009-05-07 16:31:04 EDT
This can also be reproduced on Linux by profiling Tomcat:
1. Download and setup Tomcat 5.5.27 (latest)
2. export JAVA_OPTS='-agentlib:JPIBootLoader=JPIAgent:server=enabled;HeapProf'
3. Run Tomcat's startup.sh
4. In Eclipse, under the Profiling dialog, create a new 'Attach to Agent' entry for the Linux host.
5. Move to the 'Agents' tab, bring up the filter dialogue, and remove the java* filter from the list, thus including all java* classes in the profiling data. You do not need to change any of the other filters.
6. Accept the filter change and click Profile.

Within a few moments, the Tomcat server will core (may need to use 'ulimit -c unlimited' to get the core file, depending on your Linux distro). It is not required to hit the server at all to achieve the crash.

ractest@tptp-blackhawk:~/jgw/apache-tomcat-5.5.27/bin> java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
ractest@tptp-blackhawk:~/jgw/apache-tomcat-5.5.27/bin>
Comment 3 Kathy Chan CLA 2009-05-12 17:43:00 EDT
Hi Chengrui,

Any update on this defect?  Would this be containable in TPTP 4.6?
Comment 4 Chengrui Deng CLA 2009-05-13 02:52:01 EDT
(In reply to comment #3)
> Hi Chengrui,
> 
> Any update on this defect?  Would this be containable in TPTP 4.6?
> 

Hi Kathy,
  I have found the problem cause and am working on the solution. The profiler binary for testing and patch will be submitted soon.
  
  Thanks,
  Chengrui
Comment 5 Chengrui Deng CLA 2009-05-13 02:59:32 EDT
Created attachment 135514 [details]
Add null pointer check to avoid JVM crash on attach in heapprof

The crash problem is found caused by code in HeapProf Object AllocEvent handler.

   In CObjAllocEvent::HandleEvent(SHeapEventData &data):

    ....
    if (!m_pProfEnv->m_profilerIsActive) {
        return;
    }
    m_pProfEnv->CheckClassId(data.pObjectInfo->classId);
    ....

   data.pObjectInfo maybe NULL, but it is not be checked before using in m_pProfEnv->CheckClassIddata.pObjectInfo->classId).

   This patch add additional NULL pointer check in if (!m_pProfEnv->m_profilerIsActive) and it will solve the crash problem.

   Dear committers, please help to review the patch code.

   Thanks,
   Chengrui
Comment 6 Chengrui Deng CLA 2009-05-13 03:05:43 EDT
Created attachment 135517 [details]
Profiler binary files for testing on WindowsXP

Hi, Jonathan,
  I have submitted the patch for this bug. This attachment is the profile binary files for testing on WindowsXP. Please try with it.

  Thanks,
  Chengrui
Comment 7 Jonathan West CLA 2009-05-13 10:29:00 EDT
Patched binary fixes the problem on Windows. When the fix is in the build I will test the Linux scenario on Tomcat.

Patch looks good to me.

Comment 8 Kathy Chan CLA 2009-05-13 11:06:27 EDT
Chengrui, 

Thanks for the quick turn-around!

Jonathan,

Thanks for reviewing and testing!  Could you please check the code in HEAD so that this gets into TPTP 4.6 RC1?  
Comment 9 Jonathan West CLA 2009-05-13 11:55:59 EDT
Patch checked into HEAD w/ project lead approval.
Comment 10 Jonathan West CLA 2009-06-30 10:50:55 EDT
Verified and closed.