Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 179342

Summary: dev-python/pylibpcap segfaults
Product: Gentoo Linux Reporter: Jukka Ruohonen <drear>
Component: New packagesAssignee: Python Gentoo Team <python>
Status: RESOLVED FIXED    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: strace

Description Jukka Ruohonen 2007-05-21 18:51:29 UTC
Hi.

Just started to investigate a nice looking package, pylibpcap, but did not get far.

A working example:

zealot python # whoami
root

zealot python # cat eth.py
#!/usr/bin/env python

# a nice working example
# from /usr/share/doc/pylibpcap-0.5.1/examples/findalldevs.py

import pcap

def test_findalldevs():
  print pcap.findalldevs()

test_findalldevs()

zealot python # python eth.py
at line 516
at line 516
Traceback (most recent call last):
  File "eth.py", line 10, in ?
    test_findalldevs()
  File "eth.py", line 8, in test_findalldevs
    print pcap.findalldevs()
Exception: unsupported address family
zealot python #

giving a related Grsecurity notice when run as an user

May 21 21:42:41 zealot grsec: denied resource overstep by requesting 4096 for RLIMIT_CORE against limit 0 for /usr/bin/python2.4[python:27680] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:9745] uid/euid:1000/1000 gid/egid:1000/1000

hence telling that the program segfaulted. This happens both with pylibpcap-0.5.1 and libpcap-0.9.4/0.9.5.

Strace is attached. Please request more information, as I do not know where to start to debug this.
Comment 1 Jukka Ruohonen 2007-05-21 18:52:18 UTC
zealot python # emerge --info --ignore-default-opts
Portage 2.1.2.7 (default-linux/amd64/2006.1, gcc-4.1.1, glibc-2.5-r2, 2.6.20-hardened-r2 x86_64)
=================================================================
System uname: 2.6.20-hardened-r2 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+
Gentoo Base System release 1.12.9
Timestamp of tree: Mon, 21 May 2007 01:50:01 +0000
dev-java/java-config: 1.3.7, 2.0.31-r5
dev-lang/python:     2.4.4-r4
dev-python/pycrypto: 2.0.1-r5
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.16
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -msse3 -O1 -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/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /usr/kde/*/share/apps/kjava/kjava.policy /usr/kde/*/shutdown/agent-shutdown.sh /usr/kde/3.5/share/services/rlogin.protocol"
CXXFLAGS="-march=athlon64 -msse3 -O1 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--ask --verbose"
FEATURES="buildpkg distlocks fixpackages metadata-transfer parallel-fetch sandbox sfperms suidctl userfetch userpviv usersandbox"
GENTOO_MIRRORS="http://trumpetti.atm.tut.fi/gentoo http://mirror.uni-c.dk/pub/gentoo http://ds.thn.htu.se/linux/gentoo http://mirror.gentoo.no/ http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LINGUAS="en en_GB en_US"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X alsa amd64 berkdb bitmap-fonts bzip2 cli cracklib crypt cups curl dri fortran gdbm gif gpm iconv isdnlog jpeg kde kdehiddenvisibility libg++ midi mudflap ncurses nls nptl nptlonly opengl openmp pam pcre perl png ppds pppd python qt3 readline reflection session spell spl ssl tcl tcltk tcpd tetex tiff tk truetype truetype-fonts type1-fonts unicode xcomposite xinerama xorg zlib" ALSA_CARDS="emu10k1 intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LINGUAS="en en_GB en_US" USERLAND="GNU" VIDEO_CARDS="nv"
Unset:  CTARGET, INSTALL_MASK, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Jukka Ruohonen 2007-05-21 18:52:44 UTC
Created attachment 119916 [details]
strace
Comment 3 Ali Polatel (RETIRED) gentoo-dev 2007-07-07 00:11:32 UTC
  Can you test if sniff.py under examples work fine? I can reproduce the error here but sniff.py works fine. Probably a change in libpcap caused this.
Comment 4 Jukka Ruohonen 2007-07-09 10:06:56 UTC
I confirm that sniff.py works without problems. Also all my own derivatives from it and other small functions with the package are working just fine.

If extensive debugging of the bindings to libpcap is understood to be an upstream issue, perhaps a temporal solution would be to exclude the findalldevs.py from the ebuild with the examples USE flag?
Comment 5 Ali Polatel (RETIRED) gentoo-dev 2007-07-09 13:19:10 UTC
Ok, I did some search on this one. pylibpcap raises an exception when it tries
to unpack an unknown address family. Other than that the package works fine for
sniffing. Upstream decided to silently ignore this, and return a string
indicating the family. This may not be useful but typically caller is only
interested in families that libpcap knows about. I've applied their change in
CVS to our package in the tree which makes pcap.findalldevs() work fine.

Thanks for reporting ;)