Bug 1761 - sftp exits on 2nd terminal resize after a transfer
Summary: sftp exits on 2nd terminal resize after a transfer
Status: CLOSED INVALID
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 5.5p1
Hardware: All All
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_6
  Show dependency treegraph
 
Reported: 2010-04-26 00:58 AEST by Edward Sheldrake
Modified: 2010-08-27 10:27 AEST (History)
2 users (show)

See Also:


Attachments
remove progress meter signal handlers in stop_progress_meter (351 bytes, patch)
2010-04-26 00:58 AEST, Edward Sheldrake
no flags Details | Diff
strace, sftp closing after resizes (44.68 KB, text/plain)
2010-06-26 02:53 AEST, Edward Sheldrake
no flags Details
fix for libedit (423 bytes, patch)
2010-07-20 02:22 AEST, Edward Sheldrake
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Edward Sheldrake 2010-04-26 00:58:16 AEST
Created attachment 1844 [details]
remove progress meter signal handlers in stop_progress_meter

sftp, when built with libedit (editline) support enabled, may exit unexpectedly if you resize the terminal window after a transfer.

This is with libedit 20100424-3.0 (which fixed the resize problem in libedit 20090923), but this appears to be a separate bug in sftp.

sftp handles any number of terminal resizes before a transfer, but after a file transfer, it exits after 2 consecutive terminal resizes.

I think the problem may due to signal handlers (one for SIGWINCH, the terminal resize signal) being set up in the progress meter code, but these don't seem to be removed on disposing of the progress meter. Well, at least the patch appears to fix the problem for me.
Comment 1 Damien Miller 2010-06-25 21:28:24 AEST
I can't replicate this on either OpenBSD of Ubuntu Lucid. Your patch makes sense, but I'd like to see how it crashes before applying it. Is there any change you could capture a debug/gdb trace of it crashing?
Comment 2 Edward Sheldrake 2010-06-26 02:53:31 AEST
Created attachment 1887 [details]
strace, sftp closing after resizes

The trouble is sftp doesn't crash, it exits normally. I need to work out where to put some useful breakpoints or something.

I've attached the output from strace, with several resizes before a transfer, then a transfer, and sftp closing after some more resizes. It's probably not very helpful.
Comment 3 Darren Tucker 2010-07-19 13:26:34 AEST
I can reproduce it locally (fedora 10).  I'd like to understand to root cause first before making any changes though.
Comment 4 Edward Sheldrake 2010-07-20 02:22:48 AEST
Created attachment 1904 [details]
fix for libedit

I now think this is more likely to be a libedit bug, since when running sftp, libedit's sig_handler() function only gets called on the first SIGWINCH during a read, any more seem to be ignored.

Fixing that seems to solve the problem (although I don't really know why it causes sftp to close only after a progress bar has been shown). I've emailed the libedit maintainers with my new findings.
Comment 5 Edward Sheldrake 2010-07-30 18:19:08 AEST
libedit is now fixed in cvs, so this isn't an sftp bug.
Comment 6 Darren Tucker 2010-08-27 10:27:58 AEST
With the release of OpenSSH 5.6p1 this bug is now considered closed.  If you have further problems please reopen or file a new bug as appropriate.