Menu

#128 Thread hangs in ChannelSftp.skip() following internal OutOfOrderException

v1.0 (example)
open
nobody
None
2
2019-11-08
2019-11-08
No

Hi,

We've recently found an issue where a thread that is reading data from an SFTP server gets stuck following an internal OutOfOrderException. The stack for the thread in question looks like this:

at java/lang/Object.wait(Native Method)
at java/lang/Object.wait(Object.java:218(Compiled Code))
at java/io/PipedInputStream.read(PipedInputStream.java:337(Compiled Code))
at java/io/PipedInputStream.read(PipedInputStream.java:388(Compiled Code))
at java/io/InputStream.skip(InputStream.java:246)
at com/jcraft/jsch/ChannelSftp.skip(ChannelSftp.java:2921)
at com/jcraft/jsch/ChannelSftp.access$600(ChannelSftp.java:36)
at com/jcraft/jsch/ChannelSftp$RequestQueue.cancel(ChannelSftp.java:1270)
at com/jcraft/jsch/ChannelSftp$2.read(ChannelSftp.java:1429)

I have done some investigation into this, and is appears to be related to the internal RequestQueue.

In the failure scenario, 32 requests are sent to the file server - these have identifiers 4 to 36. The OutOfOrderException occurs because response 21 is received before response 20. In this situation, the item with id 21 on the RequestQueue is cancelled - this appears to reset the entry with id 21 on the RequestQueue so that it has default values.

Following this, the code tries to cancel all of the items on the RequestQueue. However, item 21 is the first item on the RequestQueue, and has already been cancelled. When the code tries to cancel this item, and the subsequent ones on the RequestQueue, a hang occurs with the stack shown above.

This has been reproduced with both jsch 0.1.54 and 0.1.55.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB