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

Bug 437738

Summary: dev-python/pycurl-7.19.0-r1000 crashes python interpreter when calling reset too many times on a pycurl object
Product: Gentoo Linux Reporter: Christophe Farges <cfarges>
Component: Current packagesAssignee: Python Gentoo Team <python>
Status: RESOLVED FIXED    
Severity: normal CC: arfrever.fta, mgorny
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: First patch to apply to correct error
Second patch to apply to correct error
Ebuild to apply the two patchs

Description Christophe Farges 2012-10-09 16:13:39 UTC
Pycurl crashes python interpreter when calling reset too many times on a pycurl object

Sample:
---------------------
#!/bin/python
import pycurl
c = pycurl.Curl()
while True:
    c.reset()
---------------------

This script results in

Fatal Python error: deallocating None

see https://bugzilla.redhat.com/show_bug.cgi?id=624559
and https://bugzilla.redhat.com/show_bug.cgi?id=565654

Patches are available there that correct the problem

Portage 2.3.4-r9 (funtoo/1.0/linux-gnu/arch/x86-64bit, gcc-4.4.5, glibc-2.11.3, 3.4.9-gentoo x86_64)
=================================================================
System uname: Linux-3.4.9-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5345_@_2.33GHz-with-gentoo-2.2.0
Timestamp of tree: Tue, 09 Oct 2012 05:45:02 +0000
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.12-r1000
dev-lang/python:          2.7.3-r1000, 3.2.3-r1000
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.2.0-r1
sys-apps/openrc:          0.10.2-r5
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.11.6
sys-devel/binutils:       2.20.1
sys-devel/gcc:            4.4.5
sys-devel/gcc-config:     1.5-r1
sys-devel/libtool:        2.4-r3
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.11.3
Repositories: gentoo my_local_overlay
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=core2 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles metadata-transfer mini-manifest news parallel-fetch parse-eapi-ebuild-head preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="fr_FR.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
LINGUAS="fr FR"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="git://github.com/funtoo/ports-2012.git"
SYNC_USER="root"
USE="X acl alsa alsa-oss amd64 berkdb bzip2 cdr consolekit cracklib crypt cups cxx dbus dri dvd dvdr dvdread flac g3dvl gdbm gif gpm iconv ipv6 jpeg kde kerberos lame lcdfilter libnotify mad mmx modules mp3 mpeg mudflap multilib ncurses nls nptl ogg opengl openmp pam pcre png policykit pppd python qt4 readline sse sse2 ssl startup-notification tcpd tiff truetype udev unicode usb vdpau vorbis wavpack xinerama xml xorg xvid zlib zsh zsh-completion" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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 cgi cgid 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" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="fr FR" PHP_TARGETS="php5-3" PYTHON_ABIS="2.7 3.2" PYTHON_TARGETS="python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, SYNC_UMASK
Comment 1 Christophe Farges 2012-10-09 16:18:54 UTC
Additional informations:

https://rhn.redhat.com/errata/RHBA-2011-0295.html
Comment 2 Christophe Farges 2012-10-09 16:19:45 UTC
Created attachment 326096 [details, diff]
First patch to apply to correct error
Comment 3 Christophe Farges 2012-10-09 16:20:05 UTC
Created attachment 326098 [details, diff]
Second patch to apply to correct error
Comment 4 Christophe Farges 2012-10-09 16:20:56 UTC
Created attachment 326100 [details]
Ebuild to apply the two patchs
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2012-10-09 20:08:53 UTC
Comment on attachment 326100 [details]
Ebuild to apply the two patchs

--- pycurl-7.19.0-r1.ebuild     2012-10-02 01:35:28.000000000 +0200
+++ -   2012-10-09 22:08:32.116027626 +0200
@@ -1,54 +1,45 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright owners: Gentoo Foundation
+#                   Arfrever Frehtes Taifersar Arahesis
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/dev-python/pycurl/pycurl-7.19.0-r1.ebuild,v 1.9 2012/09/29 18:44:44 armin76 Exp $
 
-EAPI="4"
-PYTHON_DEPEND="2"
-SUPPORT_PYTHON_ABIS="1"
-# The selftests fail with pypy, and urlgrabber segfaults for me.
-RESTRICT_PYTHON_ABIS="3.* *-jython *-pypy-*"
+EAPI="4-python"
+PYTHON_MULTIPLE_ABIS="1"
+PYTHON_RESTRICTED_ABIS="3.* *-jython *-pypy-*"
 
 inherit distutils eutils
 
-DESCRIPTION="python binding for curl/libcurl"
+DESCRIPTION="Python binding for curl/libcurl"
 HOMEPAGE="http://pycurl.sourceforge.net/ http://pypi.python.org/pypi/pycurl"
 SRC_URI="http://pycurl.sourceforge.net/download/${P}.tar.gz"
 
 LICENSE="LGPL-2.1"
 SLOT="0"
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
+KEYWORDS="~alpha amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh sparc x86 ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
 IUSE="curl_ssl_gnutls curl_ssl_nss +curl_ssl_openssl examples ssl"
 
-# Depend on a curl with curl_ssl_* USE flags.
-# libcurl must not be using an ssl backend we do not support.
-# If the libcurl ssl backend changes pycurl should be recompiled.
-# If curl uses gnutls, depend on at least gnutls 2.11.0 so that pycurl
-# does not need to initialize gcrypt threading and we do not need to
-# explicitly link to libgcrypt.
 DEPEND=">=net-misc/curl-7.25.0-r1[ssl=]
-       ssl? (
-               net-misc/curl[curl_ssl_gnutls=,curl_ssl_nss=,curl_ssl_openssl=,-curl_ssl_axtls,-curl_ssl_cyassl,-curl_ssl_polarssl]
-               curl_ssl_gnutls? ( >=net-libs/gnutls-2.11.0 )
-       )"
+       ssl? ( net-misc/curl[curl_ssl_gnutls=,curl_ssl_nss=,curl_ssl_openssl=,-curl_ssl_axtls,-curl_ssl_cyassl,-curl_ssl_polarssl] )"
 RDEPEND="${DEPEND}"
 
-PYTHON_MODNAME="curl"
+PYTHON_MODULES="curl"
 
 src_prepare() {
        distutils_src_prepare
-       epatch "${FILESDIR}/${P}-linking-v2.patch"
+       epatch "${FILESDIR}/${P}-linking.patch"
+       epatch "${FILESDIR}/${P}-do_curl_reset-reinitialize-handle.patch"
+       epatch "${FILESDIR}/${P}-do_curl_reset_refcount.patch"
+
+       sed -e "/data_files=/d" -i setup.py || die "sed failed"
 }
 
 src_test() {
        testing() {
-               PYTHONPATH="$(ls -d build-${PYTHON_ABI}/lib.*)" "$(PYTHON)" tests/test_internals.py -q
+               python_execute PYTHONPATH="$(ls -d build-${PYTHON_ABI}/lib*)" "$(PYTHON)" tests/test_internals.py -q
        }
        python_execute_function testing
 }
 
 src_install() {
-       sed -e "/data_files=/d" -i setup.py || die "sed in setup.py failed"
-
        distutils_src_install
 
        dohtml -r doc/*
Comment 6 Mike Gilbert gentoo-dev 2013-08-11 15:48:44 UTC
Copying Arfrever since you reported this bug on Funtoo.

I'm sure it affects the Gentoo ebuilds as well.
Comment 7 Mike Gilbert gentoo-dev 2013-08-11 16:26:10 UTC
It appears upstream development has recently moved to github. I believe this is the relevant commit.

https://github.com/pycurl-devs/pycurl/commit/698e3c09cf5d05290dca91d7e2546cec9c5b1e8b
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-04-21 15:32:39 UTC
Looks like all the fixes were integrated upstream.  Can't reproduce with 7.43.0.