apt-get blocks on /dev/ptmx a lot

Bug #148806 reported by anthony baxter
2
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: apt

Frequently when doing an apt-get dist-upgrade on gutsy, apt-get just hangs. When it does this, it's stuck in a read() call on /dev/ptmx.
lsof of a hung apt-get shows a lot of open FD, all with /dev/ptmx open:
apt-get 5694 root 28u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 29u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 30u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 31u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 32u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 33u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 34u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 35u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 36u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 37u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 38u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 39u CHR 5,2 4240 /dev/ptmx
apt-get 5694 root 40u CHR 5,2 4240 /dev/ptmx

If I kill -9 it and re-run, it completes successfully. If I leave it alone, sometimes it will come back (after up to half an hour!), other times it just hangs forever.

Related branches

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your bugreport.

Do you have /dev/pts mounted when this happens? Could you please try to attach a gdb to apt-get and see if you get a useful backtrace where it sepends its time?

Thanks,
 Michael

Changed in apt:
status: New → Incomplete
Revision history for this message
anthony baxter (anthony) wrote :

backtrace:
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7c9acb3 in read () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7ede9d7 in pkgDPkgPM::DoTerminalPty ()
   from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#3 0xb7ee45ce in pkgDPkgPM::Go () from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#4 0xb7e90558 in pkgPackageManager::DoInstallPostFork ()
   from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#5 0xb7e905dd in pkgPackageManager::DoInstall ()
   from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#6 0x0805c2c8 in ?? ()
#7 0x0805f20b in ?? ()
#8 0xb7e73b2b in CommandLine::DispatchArg ()
   from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#9 0x0804ea1b in ?? ()
#10 0xb7bed050 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
#11 0x0804cec1 in ?? ()

% mount | grep pts
devpts on /dev/pts type devpts (rw,gid=5,mode=620)

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for this additional information.

The man open /devptmx are a resource leak in the process that drives dpkg. I uploaded a fix for this today.

Changed in apt:
status: Incomplete → Fix Committed
Revision history for this message
Michael Vogt (mvo) wrote :

apt (0.7.6ubuntu14) gutsy; urgency=low

  * apt-pkg/deb/dpkgpm.cc:
    - fix resource leak (LP: #148806)

 -- Michael Vogt <email address hidden> Mon, 15 Oct 2007 20:57:44 +0200

Changed in apt:
status: Fix Committed → Fix Released
Revision history for this message
anthony baxter (anthony) wrote :

Nice work! The one time I ran it today after the new apt package, it didn't lock up - but it wasn't something that happened every time, so let's leave it a day or two before saying it's fixed for sure.

Revision history for this message
Troy C (troxor) wrote :

Today I ran synaptic to remove a package, and dpkg went defunct :( I'm using the latest apt as of right now (0.7.6ubuntu14), and strace reveals that dpkg dies trying to read /dev/ptmx . some relevant info:

output from synaptic:
Removing kcontrol ...
Processing triggers for libc6 ...
ldconfig deferred processing now taking place

strace results:
root@ravana:~# readlink /proc/15359/fd/35
/dev/ptmx

Revision history for this message
Troy C (troxor) wrote :

Sorry, I managed to reproduce it by installing and then removing kcontrol again. and attach some useful info this time (hopefully!)

Also, devpts is mounted.
devpts on /dev/pts type devpts (rw,gid=5,mode=620)

Notable lines in the strace file:
3180ish to the end = Input/Output errors just before the read() hang

The last few lines for the impatient :)

select(28, [0 25 27], NULL, NULL, {1, 0}) = 1 (in [27], left {1, 0})
read(27, 0xbfd29078, 1024) = -1 EIO (Input/output error)
waitpid(16621, 0xbfd316c4, WNOHANG) = 0
---snip lots of these---
select(28, [0 25 27], NULL, NULL, {1, 0}) = 1 (in [27], left {1, 0})
read(27, 0xbfd29078, 1024) = ? ERESTARTSYS (To be restarted)
--- SIGCHLD (Child exited) @ 0 (0) ---
read(27,

here's a backtrace of apt-get on another `apt-get install kcontrol` (had to kill the one I got the strace from(
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7d50cb3 in read () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7f949d7 in pkgDPkgPM::DoTerminalPty () from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#3 0xb7f9a5ce in pkgDPkgPM::Go () from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#4 0xb7f46558 in pkgPackageManager::DoInstallPostFork () from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#5 0xb7f465dd in pkgPackageManager::DoInstall () from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#6 0x0805c2c8 in ?? ()
#7 0x08060eb2 in ?? ()
#8 0xb7f29b2b in CommandLine::DispatchArg () from /usr/lib/libapt-pkg-libc6.6-6.so.4.5
#9 0x0804ea1b in ?? ()
#10 0xb7ca3050 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
#11 0x0804cec1 in ?? ()
(gdb)

HTH, and feel free to let me know if there's any other info that would come in handy :)

Revision history for this message
Michael Vogt (mvo) wrote :

@Troy C: thanks for this information, that looks very good. What did you do to reproduce the problem? I'm not able to reproduce it here currently.

Revision history for this message
Troy C (troxor) wrote :

Simply doing `apt-get install kcontrol` and then `apt-get remove kcontrol` will cause the problem, anywhere between 10%-40% of the time.

for i in `seq 1 50` ; do apt-get -y -qq install kcontrol ; echo "install $i OK"; apt-get -y -qq remove kcontrol; echo "remove $i OK"; done

As others have mentioned, there's no immediately obvious pattern to which iteration will hang.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.