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

Bug 186080

Summary: JVMTI Profiler blocks JVM Initialization in "enabled" mode if the Agent Controller is not running
Product: z_Archived Reporter: Asaf Yaffe <asaf.yaffe>
Component: TPTPAssignee: Alexander N. Alexeev <analexee>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: P1 CC: analexee, ewchan, guru.nagarajan, igor.alelekov, jgwest, jkubasta, viacheslav.g.rybalov, vitaly.a.provodin
Version: unspecifiedKeywords: plan
Target Milestone: ---Flags: asaf.yaffe: review+
igor.alelekov: review+
Hardware: PC   
OS: Windows XP   
Whiteboard: closed460
Attachments:
Description Flags
patch
none
patched AC binary none

Description Asaf Yaffe CLA 2007-05-09 03:09:26 EDT
If the JVMTI Profiler is invoked in "enabled" mode (i.e., JPIAgent:server=enabled) and the Agent Controller is not running, the JVMTI Agent blocks the JVM initialization and waits for the Agent Controller to start. 

In "enabled" mode, the JVMTI Agent should never block the Java application. If the Agent Controller is not running, the JVMTI Agent should repeatedly try to connect but should not block.
Comment 1 Asaf Yaffe CLA 2007-05-09 03:50:41 EDT
The call to registerAgent() in ACCollector::Init() is blocking. registerAgent() waits for the Agent Controller to start and does not return until registration is successful.
Comment 2 Harm Sluiman CLA 2007-05-09 07:24:23 EDT
You are right that the PIAgent behavior is the correct one to follow, however doing some messages to the console doesn't sound consistent or correct. Plus that string would need translation if not already done.
Comment 3 Guru Nagarajan CLA 2007-05-09 09:34:25 EDT
Pls resolve this in i4
Comment 4 Viacheslav CLA 2007-05-10 09:21:19 EDT
AC framework should provide not-blocking function similar to existing registerAgent() function.

Description of the function says:
// registerAgent() establishes a private connection with the Agent Controller
// and creates a thread to get messages coming in from that connection. Does not
// return until the AC's agentRegistered response is received.
//
// 1) Creates a named pipe which this agent will use to receive commands
// coming from the Agent Controller process. This pipe cannot be used to send
// commands to the Agent Controller because the AC will never read from this pipe,
// only write to it.
// 2) Starts a thread which runs the handleMessages() function, that listens on that
// pipe for commands coming to the agent from the AC.
// 3) Sends a CONNECT command request to the AC which will result in a CONNECTION_COMPLETE
// response being received on the handleMessages thread.
// 4) Sends a registerAgent command to the AC which will result in a agentRegistered response
// being received on the handleMessages thread.
//
// returns 0 if successful
The function two times sends commands to AC and waits for responses (by semaphores).

It is easy to implement new function that starts new thread and delegates
commands sending to this thread. This may be the same thread that handles messages or other one. AC framework has all required functionality on hand.
Comment 5 Viacheslav CLA 2007-05-11 08:41:56 EDT
*** Bug 145832 has been marked as a duplicate of this bug. ***
Comment 6 Guru Nagarajan CLA 2007-05-29 19:16:22 EDT
Cannot be contained in 4.4.

Note sent to Platform Lead 5/29.
Comment 7 Guru Nagarajan CLA 2007-06-20 11:39:11 EDT
Joanna,
  Given the resources/schedule this cannot be a candidate for 4.4.0.1
Comment 8 Alexander N. Alexeev CLA 2008-01-18 09:33:45 EST
Created attachment 87259 [details]
patch 

Dedicated thread used for agent registration.
Function asyncRegisterAgent added to BaseAgentImpl for it
Comment 9 Alexander N. Alexeev CLA 2008-01-18 09:35:39 EST
Asaf, could you review the patch?
Comment 10 Asaf Yaffe CLA 2008-01-23 02:54:17 EST
Alex, 
The (simple) change to ACCollector.cpp looks good. Please ask Igor Alelekov to review the Agent Controller code changes (I have problems building the AC code in my environment).

If you can attach updated Windows IA-32 AC binaries, I can test the patch to verify that it works.
Comment 11 Alexander N. Alexeev CLA 2008-01-23 06:15:35 EST
Igor, could you review AC changes.
Comment 12 Alexander N. Alexeev CLA 2008-01-23 06:16:55 EST
Created attachment 87629 [details]
patched AC binary

Asaf, binary attached
Comment 13 Igor Alelekov CLA 2008-01-23 07:57:01 EST
The patch looks good.
Comment 14 Alexander N. Alexeev CLA 2008-01-24 09:59:26 EST
Patch committed to HEAD
Comment 15 Alexander N. Alexeev CLA 2008-01-30 07:05:41 EST
Resolving as fixed
Comment 16 Paul Slauenwhite CLA 2009-06-30 13:27:50 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.
Comment 17 Paul Slauenwhite CLA 2009-06-30 14:00:20 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.