Bug 244660 - sys-process/lsof-4.81 broken?
Bug#: 244660 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: base-system@gentoo.org Reported By: holger.hoffstaette@googlemail.com
Component: Applications
URL: 
Summary: sys-process/lsof-4.81 broken?
Keywords:  
Status Whiteboard: 
Opened: 2008-10-27 17:38 0000
Description:   Opened: 2008-10-27 17:38 0000
lsof 4.81 seemts to be broken, compared to the previously working 4.80-r1. When
invoked without arguments, it quietly exits without output. It does *not* crash
however (run in gdb). This behaviour was verified by several people on
gentoo-users.


Reproducible: Always

Steps to Reproduce:
1. emerge lsof-4.81
2. run lsof
3. no output?

Actual Results:  
no output shown

Expected Results:  
should have seen list of open file descriptors

------- Comment #1 From Holger Hoffstätte 2008-10-27 17:41:40 0000 -------
(In reply to comment #0)
In case it matters, this is on ~x86 but other users reported the same problem
on x86_64 etc.

------- Comment #2 From Volker Hemmann 2008-10-27 18:09:36 0000 -------
here a 'me too' on amd64.

Portage 2.2_rc12 (default/linux/amd64/2008.0/desktop, gcc-4.3.2,
glibc-2.8_p20080602-r0, 2.6.27.4r4 x86_64)                                      
=================================================================               
System uname:
Linux-2.6.27.4r4-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_6000+-with-glibc2.2.5 
Timestamp of tree: Mon, 27 Oct 2008 15:30:09 +0000                              
ccache version 2.4 [enabled]                                                    
app-shells/bash:     3.2_p39                                                    
dev-java/java-config: 1.3.7, 2.1.6-r1                                           
dev-lang/python:     2.5.2-r8                                                   
dev-util/ccache:     2.4-r8                                                     
dev-util/cmake:      2.6.2                                                      
sys-apps/baselayout: 2.0.0                                                      
sys-apps/openrc:     0.3.0-r1                                                   
sys-apps/sandbox:    1.2.18.1-r3                                                
sys-devel/autoconf:  2.13, 2.63                                                 
sys-devel/automake:  1.4_p6, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1            
sys-devel/binutils:  2.18-r4                                                    
sys-devel/gcc-config: 1.4.0-r4                                                  
sys-devel/libtool:   2.2.6a                                                     
virtual/os-headers:  2.6.27-r2                                                  
ACCEPT_KEYWORDS="amd64 ~amd64"                                                  
CBUILD="x86_64-pc-linux-gnu"                                                    
CFLAGS="-march=k8 -O2 -msse3 -pipe"                                             
CHOST="x86_64-pc-linux-gnu"                                                     
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config
/usr/kde/3.5/shutdown /usr/kde/4.1/env /usr/kde/4.1/share/config
/usr/kde/4.1/shutdown /usr/kde/4.2/env /usr/kde/4.2/share/config
/usr/kde/4.2/shutdown /usr/kde/svn/env /usr/kde/svn/share/config
/usr/kde/svn/shutdown /usr/share/config"                                        
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/
/etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release
/etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/
/etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo
/etc/udev/rules.d"  
CXXFLAGS="-march=k8 -O2 -msse3 -pipe"                                           
DISTDIR="/var/portage/distfiles"                                                
FEATURES="autoconfig buildpkg candy ccache distlocks parallel-fetch
preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"   
GENTOO_MIRRORS="ftp://ftp.tu-clausthal.de/pub/linux/gentoo/"                    
LANG="de_DE@euro"                                                               
LC_ALL="de_DE@euro"                                                             
LDFLAGS="-Wl,-O1"                                                               
LINGUAS="de"                                                                    
MAKEOPTS="-j3"
PKGDIR="/var/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress
--force --whole-file --delete --stats --timeout=180 --exclude=/distfiles
--exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/var/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/kdesvn-portage /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext 7zip S3TC X Xaw3d a52 aac acpi addbookmarks aiglx aim aio
akode alias alsa altenburgcards amarok amd64 amr amrnb amrwb aotuv aqua_theme
archive asf athena audiofile autoreplace avahi bash-completion berkdb
binary-drivers bluetooth boost branding bzip2 cairo captury cdda cddb cdinstall
cdparanoia cdr cdrom cdsound cegui clamav cli connectionstatus contactnotes
cpudetection cracklib crypt css cups curl dbus depth32 dhcp dio divx dnd
double-precision dpms dri dts dv dvb dvbplayer dvbsetup dvd dvdr dvdread eds
emboss emerald emovix emul-linux-x86 encode evo exif exiv2 expat exscalibar
extra-cardsets fame fasttrack ffmpeg fftw file filter_default filter_legacy
filter_light firefox fits flac fontconfig foomaticdb fortran ftp gadu gammu gd
gdbm gif gimp gimpprint glitz glut glx gnokii gnutella gpgme gpmhal hddtemp
highlight history iconv icq icu id3 id3tag ieee1394 imagemagick inotify ipv6
irc irmc isdnlog jabber java javascript jce joystick jpeg jpeg2k kate kcal kde
kdecards kdeenablefinal kdehiddenvisibility kdepim kdeprefix kdm kexi kipi lame
lapack lcms lesstif libnotify libsamplerate libwww lirc lm_sensors
logitech-mouse lzo lzw mad magic mailbox maildir maps matroska mbox
mdnsresponder-compat metric midi mikmod mime mixer mjpeg mmap mmx mmxext mngmp3
mp4 mpeg mpeg2 mplayer msn mtp mudflap mule multilib musepack music nano-syntax
ncursesneXt nepomuk net network newspr ngui nls no-old-linux nocd nosendmail
nova nowin nowlistening npp nptl nptlonly nsplugin ntfs obex offensive ogg
ogg123 ogm openexr opengl openmp oscarpam paste64 pch pcre pda pdf perl physfs
pixmaps plasma player plugins png pnm posix ppds pppd python qt3 qt3support qt4
quicktime rar readline recode reflection reiser4 reiserfs remix resolvconf
rogue rtc samba sametime sasl scanner scenarios schedule scsi sdl sdl-image
sdl-sound sdlaudio sendfile server session slp smp sms sndfile sockets sounds
spell spl sqlite sqlite3 srt sse sse-filters sse2 sse3 ssh ssl ssse3
startup-notification statistics stats stencil-buffer stroke subp subtitles svg
sysfs sysvipc szip tcpd texteffect textures tga theora threads threadsafe tiff
timidity tk tomsfastmath toolbar tools transcode translator truetype tv
tv_check tv_combiner tv_pick_cgi type1 unicode unzip usb userlocales utempter
v4l v4l2vcd videos visualization vorbis webdav webpresence wifi wireshark wmf
wmp wxwindows x264 xanim xcb xcomposite xemacs xext xface xine xml xorg xosd
xpm xrandr xrender xscreensaver xskatcards xv xvid xvmc yahoo yiff yv12 zip
zlib zsh-completion zvbi" ALSA_CARDS="emu10k1" ALSA_PCM_PLUGINS="adpcm alaw
asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa
lfloat linear meter mmap_emul mulaw multi null plug rate route share shm
softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon
authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile
authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate
dir disk_cache env expires ext_filter file_cache filter headers include info
log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling
status unique_id userdir usertrack vhost_alias" ELIBC="glibc"
INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz
cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de"
LIRC_DEVICES="devinput" USERLAND="GNU" VIDEO_CARDS="vesa v4l fglrx radeon
radeonhd"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK,
PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

------- Comment #3 From Jeroen Roovers 2008-10-27 18:44:25 0000 -------
From the 4.81 man page:
  "In the absence of any options, lsof lists all open files  belonging  to
   all active processes."

So either the man page wasn't updated or lsof is indeed broken. `lsof -u $USER'
works fine.

------- Comment #4 From David Relson 2008-10-27 23:32:52 0000 -------
Using strace it appears that both 4.80 and 4.81 are able to process
/proc/meminfo and that 4.81 dies(?) on the next item -- a socket (namely
/var/run/nscd/socket).  Here's the end of the 4.81 strace and the comparable
lines (plus a few) from 4.80's strace.  FWIW, I'll also attach the 2 straces.

########## lsof_4.81 ##########

open("/proc/meminfo", O_RDONLY)         = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f64876ca000
read(4, "MemTotal:      3920128 kB\nMemFree"..., 1024) = 630
close(4)                                = 0
munmap(0x7f64876ca000, 4096)            = 0
close(5)                                = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
close(6)                                = 0
rt_sigaction(SIGALRM, {0x410d70, [ALRM], SA_RESTORER|SA_RESTART,
0x7f64871a4430}, {SIG_DFL, [ALRM], SA_RESTORER|SA_RESTART, 0x7f64871a4430}, 8)
= 0
alarm(5)                                = 0
wait4(-1, NULL, 0, NULL)                = 15859
alarm(0)                                = 5
rt_sigaction(SIGALRM, {SIG_DFL, [ALRM], SA_RESTORER|SA_RESTART,
0x7f64871a4430}, {0x410d70, [ALRM], SA_RESTORER|SA_RESTART, 0x7f64871a4430}, 8)
= 0
exit_group(0)                           = ?

########## lsof_4.80 ##########

open("/proc/meminfo", O_RDONLY)         = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f4b81f6b000
read(4, "MemTotal:      3920128 kB\nMemFree"..., 1024) = 630
close(4)                                = 0
munmap(0x7f4b81f6b000, 4096)            = 0
* socket(PF_FILE, SOCK_STREAM, 0)         = 4
* fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
* connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
* close(4)                                = 0
* socket(PF_FILE, SOCK_STREAM, 0)         = 4
* fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
* connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
* close(4)                                = 0

...[snip]...

exit_group(0)                           = ?

------- Comment #5 From David Relson 2008-10-27 23:34:28 0000 -------
Created an attachment (id=170046) [details]
strace of lsof-4.80

------- Comment #6 From David Relson 2008-10-27 23:35:58 0000 -------
Created an attachment (id=170048) [details]
strace of lsof-4.81

------- Comment #7 From Joshua Kinard 2008-11-02 17:41:55 0000 -------
Fixed in lsof-4.81-r1.

There was an over-zealous rejection of open file listings when no options were
specified on the command line and security was enabled.  The upstream author
pinned down the bug after I found out that enabling HASSECURITY and
HASNOSOCKSECURITY triggered the bug.