Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 497878 - net-irc/irssi-xmpp-0.52 - segmentation faults in func_sort_resource()
Summary: net-irc/irssi-xmpp-0.52 - segmentation faults in func_sort_resource()
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2014-01-12 09:41 UTC by Edward "Hades"
Modified: 2017-01-22 15:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch with NULL checks for func_sort_resource (irssi-xmpp-func_sort_resource-segfault.patch,772 bytes, patch)
2014-01-12 09:48 UTC, Edward "Hades"
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Edward "Hades" 2014-01-12 09:41:11 UTC
irssi-xmpp seems to segfault randomly. I've gathered a backtrace, and it seems that one of the strings becomes NULL all of a sudden, and there is no check for it in the func_sort_resource.

I am attaching a patch that adds checks for NULL strings.

Reproducible: Sometimes

Steps to Reproduce:
1. Run irssi with irssi-xmpp for quite a long time.
2. Having not forgotten `ulimit -c unlimited` or attaching gdb :)
Comment 1 Edward "Hades" 2014-01-12 09:43:37 UTC
# emerge --info irssi irssi-xmpp
Portage 2.2.7 (default/linux/amd64/13.0, gcc-4.6.3, glibc-2.16.0, 3.11.0-gentoo x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.11.0-gentoo-x86_64-Intel-R-_Core-TM-_i5_CPU_M_560_@_2.67GHz-with-gentoo-2.2
KiB Mem:     3837324 total,    209224 free
KiB Swap:    4194300 total,   2937228 free
Timestamp of tree: Sun, 29 Dec 2013 12:30:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-java/java-config:     2.1.12-r1
dev-lang/python:          2.7.5-r3, 3.3.2-r2
dev-util/cmake:           2.8.11.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.3.6-r1, 4.6.3, 4.7.3-r1, 4.8.1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.9 (virtual/os-headers)
sys-libs/glibc:           2.16.0
Repositories: gentoo kde proaudio stuff wtk science
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -march=native -pipe"
FEATURES="assume-digests binpkg-logs buildsyspkg compressdebug config-protect-if-modified distlocks downgrade-backup ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-backup unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -march=native -pipe"
GENTOO_MIRRORS="http://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ http://gentoo.mneisen.org/ http://de-mirror.org/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/kde /var/lib/layman/pro-audio /var/lib/layman/stuff /var/lib/layman/wtk /var/lib/layman/science"
USE="256-color X aac acl acpi aes alsa amd64 aperfmperf apic arat arch_perfmon avx bash-completion berkdb branding bts bzip2 caps cdda cddb clflush cli cmov constant_tsc cracklib crypt cups cx16 cx8 cxx dbus de djvu doc dri ds_cpl dtes64 dts dvd emovix encode ept est exif ffmpeg flac flexpriority fortran fpu fxsr gdbm git gpg ht iconv ida imap ipv6 jack jpeg jpeg2k lahf_lm lame lastfm lm lzma mca mce mmx modules monitor mp3 msr mtrr mudflap multilib musicbrainz ncurses network nls nntp nonstop_tsc nopl nptl nx offensive ogg opengl openmp pae pam pat pbe pcid pclmulqdq pcre pdcm pdf pebs pge png pni popcnt postgres postscript pse pse36 python qt3support qt4 rdtscp readline rep_good sasl semantic-desktop sep session smime smp smx sox sqlite ss sse sse2 sse3 sse4_1 sse4_2 ssl ssse3 subversion svg syscall taglib tcpd theora tiff tm tm2 tpr_shadow tsc unicode vim-syntax vme vmx vnmi vorbis vpid wavpack x264 xcb xinerama xtopology xtpr xvid zlib" ABI_X86="64" 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" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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 author" 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 ublox ubx" INPUT_DEVICES="evdev keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US en_GB ru ru_RU de de_DE" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19" USERLAND="GNU" VIDEO_CARDS="intel vesa fbdev" 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, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

net-irc/irssi-0.8.15-r1 was built with the following:
USE="ipv6 (multilib) perl ssl -socks5" ABI_X86="64"


net-irc/irssi-xmpp-0.52 was built with the following:
USE="(multilib)" ABI_X86="64"
Comment 2 Edward "Hades" 2014-01-12 09:47:25 UTC
Program received signal SIGSEGV, Segmentation fault.
0x00007ff80fe2b47a in __strcmp_sse42 () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ff80fe2b47a in __strcmp_sse42 () from /lib64/libc.so.6
#1  0x00007ff80eae70d4 in func_sort_resource (resource1_ptr=0x3410e60, resource2_ptr=0x2de5480) at rosters.c:90
#2  0x00007ff810bdd5ca in g_slist_sort_real () from /usr/lib64/libglib-2.0.so.0
#3  0x00007ff80eae7fde in update_user_presence (server=0x2381d30, full_jid=0x34b7e60 "<...>", 
    show_str=0x34e1ab0 "away", status=0x0, priority_str=0x0) at rosters.c:391
#4  0x00007ff80eae85dc in sig_recv_presence (server=0x2381d30, lmsg=0x24fc130, type=-1, id=0x7ff80eaf40fe "", 
    from=0x34b7e60 "<...>", to=0x2ef91f0 "<...>") at rosters.c:499
#5  0x00000000004ab14f in signal_emit_real (rec=0x18fea90, params=6, va=0x7fff2e47da48, first_hook=0x18ff7e0) at signals.c:242
#6  0x00000000004ab38b in signal_emit (signal=0x7ff80eaf4119 "xmpp recv presence", params=6) at signals.c:286
#7  0x00007ff80eae9671 in handle_stanza (handler=0x23ba390, connection=0x3319030, lmsg=0x24fc130, user_data=0x2381d30) at stanzas.c:79
#8  0x00007ff80e8c98a0 in connection_message_queue_cb () from /usr/lib64/libloudmouth-1.so.0
#9  0x00007ff80e8cac77 in message_queue_dispatch_func () from /usr/lib64/libloudmouth-1.so.0
#10 0x00007ff810bc2b63 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#11 0x00007ff810bc2ea8 in g_main_context_iterate.isra.23 () from /usr/lib64/libglib-2.0.so.0
#12 0x00007ff810bc2f64 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#13 0x0000000000431a86 in main (argc=1, argv=0x7fff2e47ddc8) at irssi.c:356
(gdb) frame 1
#1  0x00007ff80eae70d4 in func_sort_resource (resource1_ptr=0x3410e60, resource2_ptr=0x2de5480) at rosters.c:90
90                      return strcmp(resource1->name, resource2->name);
(gdb) list
85
86              resource1 = (XMPP_ROSTER_RESOURCE_REC *)resource1_ptr;
87              resource2 = (XMPP_ROSTER_RESOURCE_REC *)resource2_ptr;
88              if ((cmp = resource2->priority - resource1->priority) == 0
89                  && (cmp = resource2->show - resource1->show) == 0)
90                      return strcmp(resource1->name, resource2->name);
91              return cmp;
92      }
93
94      static int
(gdb) p resource1
$1 = (XMPP_ROSTER_RESOURCE_REC *) 0x3410e60
(gdb) p resource2
$2 = (XMPP_ROSTER_RESOURCE_REC *) 0x2de5480
(gdb) p resource1->name
$3 = 0x2fe9cd0 "MessagingA3f782e26"
(gdb) p resource2->name
$4 = 0x0
Comment 3 Edward "Hades" 2014-01-12 09:48:36 UTC
Created attachment 367704 [details, diff]
patch with NULL checks for func_sort_resource
Comment 4 grey dot 2014-03-19 12:01:11 UTC
(In reply to Edward "Hades" from comment #3)
> Created attachment 367704 [details, diff] [details, diff]
> patch with NULL checks for func_sort_resource

WUT?

>+	    	if (resource1->name == resource2->name)
>+			return 0;

Remove these two lines please. Those are very unlikely to be equal ever unless resource1 == resource2.
Comment 5 Douglas J Hunley 2015-10-14 13:35:01 UTC
This appears to be http://gna.org/bugs/?20487 which is fixed in 0.52-2 (https://launchpad.net/ubuntu/+archive/primary/+files/irssi-plugin-xmpp_0.52-2_amd64.deb)

Any chance we can get a revbump?
Comment 6 Pacho Ramos gentoo-dev 2015-11-04 17:00:52 UTC
are you willing to proxy maintain this?
https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers
Comment 7 Pacho Ramos gentoo-dev 2017-01-22 15:06:07 UTC
please retry with 0.53