It is very easy to reproduce the bug. The idea is that when one tries to write something to an OutputStream of already finished process (ChannelExec), jsch sends bytes to the remote sshd and gets 'Received data for nonexistent channel' back. Bad thing about this is that once this 'exception' is received, JSch closes the whole Session. This leads in terminating all other processes started in the same session.
So to reproduce the bug one can create and start ChannelExec for a short-running application (/bin/echo) and try to write something into it's OutputStream..
To show how it affects other processes I have attached a small example.
It demonstrates the problem this way:
1. it opens a new ssh session
2. creates and starts ChannelExec for a long-running process (sleep 3)
3. starts a Thread that waits for sleep termination
4. creates and starts ChannelExec for a short-running process (echo) (within the SAME Session)
5. tries to write some data to echo's OutputStream
=> data for non-existent channel problem => JSch closes the session => sleep is also terminated
Log in to post a comment.