vlc hangs after exiting when its stderr is redirected to stdout

Bug #897341 reported by Daniel Hahler
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
VLC media player
Invalid
Undecided
Unassigned
vlc (Ubuntu)
Invalid
Undecided
Unassigned
xdg-utils (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

When redirecting stderr to stdout, vlc hangs for some seconds:

With redirect:
% time vlc --play-and-exit ~/Videos/foo.avi 2>&1 | grep foo
vlc --play-and-exit ~/Videos/foo.avi 2>&1 0.46s user 0.15s system 35% cpu 1.712 total
grep foo 0.00s user 0.00s system 0% cpu 50.937 total

Normal:
% time vlc --play-and-exit ~/Videos/foo.avi | grep foo
VLC media player 1.1.12 The Luggage (revision exported)
Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")
Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")
[0x9c0692c] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Blocked: call to setlocale(6, "")
Blocked: call to setlocale(6, "")

(process:31781): Gtk-WARNING **: Locale not supported by C library.
 Using the fallback 'C' locale.
Blocked: call to setlocale(6, "")
xdg-screensaver: Window 0x054001c5 does not exist
vlc --play-and-exit ~/Videos/foo.avi 0.44s user 0.14s system 37% cpu 1.548 total
grep foo 0.00s user 0.00s system 0% cpu 1.417 total

I am using this to find out if a file has been played completely (by grepping for "main playlist: end of playlist, exiting").

This used to work as expected (without a timeout of ~50 seconds), but has regressed during the last months (maybe when upgrading to Ubuntu Oneiric).

I have tested a nightly snapshot (1.2.0~~git20111110+r996-0~r47~oneiric1), which has the same problem.

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: vlc 1.1.12-2~oneiric1
ProcVersionSignature: Ubuntu 3.0.0-14.23-generic-pae 3.0.9
Uname: Linux 3.0.0-14-generic-pae i686
ApportVersion: 1.23-0ubuntu4
Architecture: i386
Date: Mon Nov 28 19:42:42 2011
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release i386 (20110427.1)
SourcePackage: vlc
UpgradeStatus: Upgraded to oneiric on 2011-09-29 (59 days ago)

Revision history for this message
Daniel Hahler (blueyed) wrote :
description: updated
Daniel Hahler (blueyed)
description: updated
Revision history for this message
Rémi Denis-Courmont (rdenis) wrote :

Manually updating upstream status.

Changed in vlc:
importance: Unknown → Undecided
status: Unknown → New
status: New → Invalid
Revision history for this message
Rémi Denis-Courmont (rdenis) wrote :

I am not able to reproduce the problem with the provided instructions.

Please interrupt the process while it is stuck and make a threaded backtrace from that.

Changed in vlc (Ubuntu):
status: New → Incomplete
Revision history for this message
Daniel Hahler (blueyed) wrote :

Thanks Rémi for following up.

It looks like the "grep" process is the one blocking/waiting and it tends to wait 0-60 seconds, like there is a timeout of about one minute in grep / I/O handling.

When suspending the command after closing vlc it looks like this:
% vlc --play-and-exit foo.avi 2>&1 | grep foo
^Z
[2] + 17237 done vlc --play-and-exit 2>&1 |
       17238 suspended grep foo

Should I now attach gdb to grep? This looks as follows, but I am missing the debug symbols for grep (where can those be found?):
(gdb) bt
#0 0xb77c9424 in __kernel_vsyscall ()
#1 0xb76d8153 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:82
#2 0x0804cb3d in ?? ()
#3 0x0804e29b in ?? ()
#4 0x0804a88d in ?? ()
#5 0xb76174d3 in __libc_start_main (main=0x8049cf0, argc=2, ubp_av=0xbf9c0564, init=0x8066330,
    fini=0x80663a0, rtld_fini=0xb77d9280 <_dl_fini>, stack_end=0xbf9c055c) at libc-start.c:226
#6 0x0804adf5 in ?? ()

Changed in vlc (Ubuntu):
status: Incomplete → Invalid
Daniel Hahler (blueyed)
Changed in vlc:
importance: Undecided → Unknown
status: Invalid → Unknown
Revision history for this message
Rémi Denis-Courmont (rdenis) wrote :

Synching upstream state manually AGAIN. Please stop this.

Changed in vlc:
importance: Unknown → Undecided
status: Unknown → New
status: New → Invalid
Revision history for this message
Daniel Hahler (blueyed) wrote :

It appears to be a bug with xdg-utils, or at least triggered from there:

Looking at the strace output, there's a sleep process being invoked, which "hangs"/waits in the end:

    15202 0.000070 execve("/bin/sleep", ["sleep", "50"], [/* 71 vars */] <unfinished ...>

This originates from /usr/lib/vlc/plugins/misc/libxdg_screensaver_plugin.so (where it gets cloned/created from).

Use of this plugin/feature can be toggled in VLC using the "disable-screensaver" setting, which I have enabled (appears to be the default).

This comes from screensaver_suspend_loop out of xdg-screensaver from xdg-utils:

    (while [ -f "$screensaver_file" ]; do $*; sleep 50; done) > /dev/null 2> /dev/null &

This background process seems to be blocking, if stderr is being redirected from vlc, and stdout being read by e.g. grep.

I have not investigated how this worked previously, but it must have changed somehow.

Is there a way to make the "vlc pipeline" end before the subprocess ends itself?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in xdg-utils (Ubuntu):
status: New → Confirmed
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.