Bug 869442

Summary: uniq -c crashes while "uniq -c" from GNU Coreutils OK.
Product: [Fedora] Fedora Reporter: Shlomi Fish <shlomif>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: admiller, kdudka, kzak, ovasik, p, twaugh, yu.valery+bugzilla
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-23 04:08:07 EST Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
Input Causing uniq -c to crash after compressed with xz. none

Description Shlomi Fish 2012-10-23 18:21:59 EDT
Created attachment 632427 [details]
Input Causing uniq -c to crash after compressed with xz.

Description of problem:

With the attachment, doing:

unxz < uniq-c.crash.txt.xz | uniq -c

generates an indication of a Segmentation fault on both Mageia 2 x86-64 and
Mageia Cauldron x86-64. This does not happen with unxz < uniq-c.crash.txt.xz |
~/apps/temp-coreutils/bin/uniq -c (where this uniq was installed using
"./configure --prefix="$HOME/apps/temp-coreutils" ; "make" ; "make install"
from the GNU coreutils sources).

The file contains a long line of items separated by CRs, due to a
mis-generation (which was since fixed) but uniq still should not crash.

How reproducible:

Always

Steps to Reproduce:
1. unxz < uniq-c.crash.txt.xz | uniq -c
  
Actual results:

Segfault.

Expected results:

Correct output returned.

Additional info:

See https://bugs.mageia.org/show_bug.cgi?id=7592

After some amount of investigation (thanks to Luigi12_work from IRC for
some insights), we found out that the problem was with
coreutils-8.19-new-i18n.patch patch. If we remove it, do "bm -l -p" and run
"./configure --prefix ; make ; make install", then the unxz < ... |
~/apps/temp-coreutils-rpm/uniq -c works fine. With all patches applied it
segfaults.

This patch is identical to this Fedora patch:

http://pkgs.fedoraproject.org/cgit/coreutils.git/plain/coreutils-i18n.patch
Comment 1 Ondrej Vasik 2012-10-24 03:33:09 EDT
Thanks for report, confirmed. You can just use 'LC_ALL=C uniq -c' to disable the multibyte path for this case.
Comment 2 yu.valery+bugzilla 2013-01-22 09:28:46 EST
It also affects sort and join
http://permalink.gmane.org/gmane.comp.security.oss.general/9215
Comment 3 Ondrej Vasik 2013-01-22 15:20:20 EST
SUSE fix is to use xmalloc and free instead of alloca ... makes sense - https://build.opensuse.org/package/rdiff?linkrev=base&package=coreutils&project=Base%3ASystem&rev=173 is the link to the commit. I'll make an update tomorrow.
Comment 4 Ondrej Vasik 2013-01-23 04:08:07 EST
Fixed in Rawhide - coreutils-8.20-6.fc19 - http://lists.fedoraproject.org/pipermail/scm-commits/2013-January/933514.html . CLOSING RAWHIDE (will prepare updates for lower Fedoras based on #902917)
Comment 5 Fedora Update System 2013-01-30 11:18:45 EST
coreutils-8.15-10.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/coreutils-8.15-10.fc17
Comment 6 Fedora Update System 2013-03-12 04:51:09 EDT
coreutils-8.15-10.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.