Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 193304

Summary: [transport] Transport SendData returns -1 and causes trace events loss
Product: z_Archived Reporter: Ruslan Scherbakov <ruslan.scherbakov>
Component: TPTPAssignee: Igor Alelekov <igor.alelekov>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: P1 CC: asaf.yaffe, guru.nagarajan, jgwest, jkubasta, ruslan.scherbakov, samwai, sluiman, viacheslav.g.rybalov
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: closed460
Bug Depends on:    
Bug Blocks: 190687    
Attachments:
Description Flags
Java2Demo.jar
none
servicelog.log
none
Profiler outputs
none
patch none

Description Ruslan Scherbakov CLA 2007-06-19 07:58:35 EDT
Config:
 win_ia32-TPTP-4.4.0-200706180100
 running RAC with modified JPIAgent (added tracing of returned result from transport SendData)
 sun-jdk1.5.0_06-windows-ia32 or sun-jre1.5.0_11-win-ia32

Test case (not reproducable 100%, it is needed to make several attempts):
 1. run RAC
 2. run Eclipse on clean workspace
 3. run java -agentlib:JPIBootLoader=JPIAgent:server=enabled;HeapProf -jar tools\Java2Demo.jar
 4. open attach dialog, select mem analys and do attach
 5. open mem analys (Object Allocations) view after successfull attach

As result: unknown methods are displayed (bug #190687)
50 events are transferred OK after traceStart. Next ~60 are lost. Then all other event again are send successfully.
Deeper analysis shows that on back end side the transport method returns -1 and cuts events including classdefs.

Added check in JPIAgent Print.cpp CPrint::jvmtiAgent_print method for return result and printed to the file:
  int res1 = (m_pfSendData)(s, length); // res1 is printed to file then

m_pfSendData is initialized by:
m_pfSendData = (Martini::ACCollector::ACCollector_SendData_t)(libraryLoader->GetEntry("ACCollector_SendData"));
and I do not know exactly what transport library is used in this case.
Comment 1 Igor Alelekov CLA 2007-06-19 10:24:08 EDT
Ruslan, could you tell what is the Java2Demo.jar?
Please submit a servicelog.log dile with DEBUG level.
Comment 2 Ruslan Scherbakov CLA 2007-06-20 01:46:59 EDT
Created attachment 71830 [details]
Java2Demo.jar
Comment 3 Ruslan Scherbakov CLA 2007-06-20 01:59:32 EDT
Created attachment 71833 [details]
servicelog.log

with sun-jre1.5.0_11-win-ia32
and agntctrl.win_ia32-TPTP-4.4.0-200706180100
Comment 4 Igor Alelekov CLA 2007-06-20 02:02:41 EDT
Thanks,
once more question :)
How it could be seen that "Next ~60 are lost"?
Comment 5 Ruslan Scherbakov CLA 2007-06-20 02:11:17 EDT
Created attachment 71835 [details]
Profiler outputs

The missed events can be found in the attached dump_1182247475343_trace.trcxml by -1 indication in format:
...
<classDef name="[F" sourceName="&lt;Unknown&gt;" classId="2147483649" time="1182247474.587285694"/>
99=-1
...

This events do not reach the client (dump_1182247475343_1.out) and client socket (dump_1182247475273_3.out).
Comment 6 Igor Alelekov CLA 2007-06-20 09:20:08 EDT
Created attachment 71874 [details]
patch

jvmti.runtime patch Ruslan reviewed and tested
Comment 7 Harm Sluiman CLA 2007-06-20 09:46:46 EDT
(In reply to comment #6)
> Created an attachment (id=71874) [details]
> patch
> jvmti.runtime patch Ruslan reviewed and tested


I don't claim to understand the general code base, but this patch basically reduces the number cases a variable is set. So I am curious how much testing was done for all the "else" cases that are now exposed. Does the data listener only need to be set for this one command? 
Comment 8 Igor Alelekov CLA 2007-06-20 09:58:24 EDT
Currently, several clients (5) attach to the agent and send resume/run.. commands simultaneously. 
Only one client establishes data channel. Variable m_dataListenerID should be initialized with this data channel id. But currently it is set with every incomming command from all clients. And agent tries to send data to the originator of the last command. And if it hasn't data channel, data are lost.
The patch allows sending data on last established data channel only.
Comment 9 Harm Sluiman CLA 2007-06-20 10:54:51 EDT
(In reply to comment #8)
> Currently, several clients (5) attach to the agent and send resume/run..
> commands simultaneously. 
> Only one client establishes data channel. Variable m_dataListenerID should be
> initialized with this data channel id. But currently it is set with every
> incomming command from all clients. And agent tries to send data to the
> originator of the last command. And if it hasn't data channel, data are lost.
> The patch allows sending data on last established data channel only.

Thanks, this is the logic I was expecting. The issue then becomes testing since there may be problem that have been dependent on or hidden by the behaviour that is being fixed.
Comment 10 Oliver Schoett CLA 2007-06-20 13:04:09 EDT
Please don't let Comment #9 deter you from checking in the patch.  With *every* patch that fixes a grave bug by which some function did not work at all, there is the problem that the grave bug might have masked some other bugs in that function.  These bugs will only become apparent after the patch has been checked in, and it is not the patcher's responsibility to test for possible further bugs that had been masked.

[I need to profile JVM 1.6 machines with JVMTI and am currently blocked by the dependent bug 190687.]
Comment 11 Harm Sluiman CLA 2007-06-21 08:17:16 EDT
(In reply to comment #10)
I agree Oliver. My questions about testing are actually to the folks that will role this fix in and if it can be contained in the Europa driver we are supposed to provide today, and not at all a question of taking the fix.
Comment 12 jkubasta CLA 2007-06-21 10:21:28 EDT
To be delivered in 4.4
Comment 13 jkubasta CLA 2007-06-21 10:22:13 EDT
Samson, please commit the patch and resolve the defect as the PMC has approved inclusion of this fix in 4.4
Comment 14 Samson Wai CLA 2007-06-21 10:31:32 EDT
Patch checked into CVS 2007/06/21 10:30 EDT.
Comment 15 Paul Slauenwhite CLA 2009-06-30 12:07:42 EDT
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant enhancements/defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this enhancement/defect is verified/closed by the Project Lead since this enhancement/defect has been resolved and unverified for more than 1 year and considered to be fixed. If this enhancement/defect is still unresolved and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.