Bug 292423 - qaptworker does not clears pty master
Summary: qaptworker does not clears pty master
Status: RESOLVED FIXED
Alias: None
Product: muon
Classification: Applications
Component: qaptworker (show other bugs)
Version: 1.2.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Jonathan Thomas
URL:
Keywords:
: 293266 293578 296237 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-26 00:48 UTC by Ilia K.
Modified: 2012-03-17 22:30 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 1.2.95


Attachments
quick and dirty fix. Warning: absolutely untested (even not compiled). (758 bytes, patch)
2012-01-26 00:48 UTC, Ilia K.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ilia K. 2012-01-26 00:48:33 UTC
Created attachment 68176 [details]
quick and dirty fix. Warning: absolutely untested (even not compiled).

Version:           1.2.1 (using KDE 4.7.4) 
OS:                Linux

qaptworker opens a new pty before running dpkg, but it seems like it never reads from pty master. This may lead to child being blocked while trying to write to stdout/stderr (which is a pty slave). See for example https://bugs.launchpad.net/ubuntu/+source/qapt/+bug/840306


Reproducible: Didn't try

Steps to Reproduce:
Run some package install/update which generates lots of output.

Actual Results:  
Muon hangs with child processes blocked in write(1, ...) system call.

Expected Results:  
guess what

I attach a quick and dirty patch against git master, which adds 3 lines. I don't have a KDE build system ready at hand, so I event didn't build it. I am also not an expert on PTYs. Keep in mind when applying the patch :)
Comment 1 Jonathan Thomas 2012-01-26 04:13:09 UTC
This makes sense.

In the beginning, we only had the pipe from dpkg which outputted status messages to an fd we provided to dpkg. Otherwise, dpkg was running in a totally non-interactive environment without even stdout. Later when a dpkg update caused issues (lack of stderr, which wasn't a problem before due to a bug in dpkg where it leaked an stderr fd) the pty got put in so that dpkg wouldn't crap itself when something stderr'd.

But the QApt Worker never used the pty's stdout for anything, so it never gets read/cleared. Reading the pipe documentation, when a pipe is full a write will fail with -EAGAIN, which is exactly what has been documented as having occurred with this bug. Regularly clearing out the pipe seems to be exactly what needs to be done to fix this.

I may add additional functionality to QApt for reporting the full dpkg output later, but since we're in feature freeze for 1.3 I'll just apply this patched (which I tested with a 250 package upgrade, no problems) and worry about new features later.

Thanks a million!
Comment 2 Jonathan Thomas 2012-01-26 04:22:45 UTC
Git commit a97cf75726e62930709a42f8d5c67b700200d282 by Jonathan Thomas.
Committed on 26/01/2012 at 05:04.
Pushed by jmthomas into branch '1.2'.

The pty we open pipes dpkg's raw output to a file descriptor. We were never reading this,
so when dpkg's stdout/stderr filled this pipe dpkg would hang waiting for the slave to
read some data off it. This caused the QApt Worker to hang on verbose/long upgrades.

Thanks to Ilia K. for the patch.

>From what I can remember PackageKit's aptcc backend used the same pty scheme as QApt,
since both patches were written by the same person, so you guys may want to pick this
one up as well.
FIXED-IN:1.2.95, 1.2.3
CCMAIL:Matthias Klumpp <matthias@tenstral.net>

M  +4    -0    src/worker/workerinstallprogress.cpp

http://commits.kde.org/libqapt/a97cf75726e62930709a42f8d5c67b700200d282
Comment 3 Jonathan Thomas 2012-01-26 04:22:46 UTC
Git commit ba99de0623782ef2b2da50b50250940bc5a507ec by Jonathan Thomas.
Committed on 26/01/2012 at 05:04.
Pushed by jmthomas into branch 'master'.

The pty we open pipes dpkg's raw output to a file descriptor. We were never reading this,
so when dpkg's stdout/stderr filled this pipe dpkg would hang waiting for the slave to
read some data off it. This caused the QApt Worker to hang on verbose/long upgrades.

Thanks to Ilia K. for the patch.

>From what I can remember PackageKit's aptcc backend used the same pty scheme as QApt,
since both patches were written by the same person, so you guys may want to pick this
one up as well.
FIXED-IN:1.2.95, 1.2.3
CCMAIL:Matthias Klumpp <matthias@tenstral.net>

M  +4    -0    src/worker/workerinstallprogress.cpp

http://commits.kde.org/libqapt/ba99de0623782ef2b2da50b50250940bc5a507ec
Comment 4 Jonathan Thomas 2012-01-27 04:28:39 UTC
*** Bug 292549 has been marked as a duplicate of this bug. ***
Comment 5 Jonathan Thomas 2012-02-05 17:26:46 UTC
*** Bug 293266 has been marked as a duplicate of this bug. ***
Comment 6 Jonathan Thomas 2012-02-08 00:09:23 UTC
*** Bug 293578 has been marked as a duplicate of this bug. ***
Comment 7 Jonathan Thomas 2012-03-17 22:30:54 UTC
*** Bug 296237 has been marked as a duplicate of this bug. ***