This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 279837 - [ssh][shells] RemoteCommandShellOperation can miss output
Summary: [ssh][shells] RemoteCommandShellOperation can miss output
Status: CLOSED MOVED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3.1   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-10 13:47 EDT by David McKnight CLA
Modified: 2024-10-28 14:58 EDT (History)
0 users

See Also:
mober.at+eclipse: pmc_approved-


Attachments
patch to use getOutputAt() (3.42 KB, patch)
2009-06-10 13:49 EDT, David McKnight CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David McKnight CLA 2009-06-10 13:47:50 EDT
It's possible for RemoteCommandShellOperation to miss output when reading from the shell via IRemoteCommandShell.listOutput().  Instead, it should use IRemoteCommandShell.getOutputAt().
Comment 1 David McKnight CLA 2009-06-10 13:49:28 EDT
Created attachment 138830 [details]
patch to use getOutputAt()
Comment 2 David McKnight CLA 2009-06-10 15:46:16 EDT
Martin, I don't suppose there's any change for this to make it into RSE 3.1.  The change is low-risk since nothing within base-RSE uses RemoteCommandShellOperation.
Comment 3 Martin Oberhuber CLA 2009-06-10 16:21:31 EDT
Go get a reviewer, I'm reviewing as well. Let's see what we can do.
Comment 4 David McKnight CLA 2009-06-10 16:24:02 EDT
Xuan, could you review this?  Thanks.
Comment 5 Martin Oberhuber CLA 2009-06-10 17:51:09 EDT
I don't see how your patch would solve the problem. The 
   outputUpdated()
method which you changed is called repeatedly on the main thread, and will work on the amount of output that's available at that particular time. In the meantime, another thread generates output. Your change only means that addidional output gets captured, which happens to be created during the (really short) time in which we perform parsing. The original code took a snapshot at the time the main thread invoked outputUpdated().

It seems to me that taking a snapshot is not necessarily wrong, since outputUpdated() will be called again later with the next chunk of data anyways. 
After all we remember the index where we stopped parsing the last time. Even with your changed code it could happen that additional output gets created and we miss it due to some race condition.

Why do you think this is Major?
How often is failure observed and what is the impact of failure on the user?
Could you confirm with a test that your code actually works as expected?

Again, this fix looks like an ideal candidate for a Unit test which exercises the function a 1000 times or so in order to get confidence that it actually works properly. Without such a Unit test, I don't think that changing this such late in the game is the right thing to do. I might be swayed with very clear arguments and a unit test. If you don't feel like trying to push this into 3.1 please set an appropriate target milestone.
Comment 6 David McKnight CLA 2009-06-10 18:53:34 EDT
After investigating this further, it turns out that my patch simply altered the timing so that my scenarios were working.  The real difficulty I hit is with SshServiceCommandShell.shellOutputChanged():

        ...
	if (!gotCommand && line.equals(_curCommand)) {
	   gotCommand = true;
	   continue; //ignore remote command echo
        }
        ...

RemoteCommandShellOperation waits until it receives the echo of the command before it starts processing output (so that it can ignore shell initialization text).  Because the ssh service swallows the command echo, the RemoteCommandShellOperation never gets a chance to process the output.  I'm not sure how we can get around that.

I marked the bug as major because it takes away functionality for console IO in an IBM launch scenario.

Comment 7 David McKnight CLA 2009-06-12 11:13:40 EDT
Martin, do you have any suggestions on how to deal with this use case of SshServiceCommandShell?
Comment 8 Martin Oberhuber CLA 2009-06-17 13:55:25 EDT
not at the moment.
Comment 9 David McKnight CLA 2010-12-22 09:14:13 EST
Bulk moving 3.2.x bugs to 3.3
Comment 10 Martin Oberhuber CLA 2011-05-31 17:49:05 EDT
Bulk moving 3.3 deferred items to 3.3.1
Comment 11 Eclipse Webmaster CLA 2024-10-28 14:58:43 EDT
This issue has been migrated to https://gitlab.eclipse.org/eclipse/tm/org.eclipse.tm/-/issues/529.