Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 564936 - app-emulation/qemu: check_targets sort is not stable across locales
Summary: app-emulation/qemu: check_targets sort is not stable across locales
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo QEMU Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-05 12:40 UTC by Mads
Modified: 2015-11-10 01:17 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mads 2015-11-05 12:40:48 UTC
Locales with lexical sorting that differs from english will choke on the ebuild function "check_targets()" in qemu ebuilds with aarch64 in the target lists.

Reproducible: Always

Steps to Reproduce:
LC_ALL=nb_NO.UTF-8 emerge -v qemu
Actual Results:  
>>> Emerging (1 of 1) app-emulation/qemu-2.4.0.1-r1::gentoo
 * qemu-2.4.0.1.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                                                             [ ok ]
>>> Unpacking source...
>>> Unpacking qemu-2.4.0.1.tar.bz2 to /var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/work
>>> Source unpacked in /var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/work
>>> Preparing source in /var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/work/qemu-2.4.0.1 ...
 * The ebuild needs to be kept in sync.
 * IUSE_SOFTMMU_TARGETS: cris i386 lm32 m68k microblaze microblazeel mips mips64 mips64el mipsel moxie or32 ppc ppc64 ppcemb s390x sh4 sh4eb sparc sparc64 tricore unicore32 x86_64 xtensa xtensaeb aarch64 alpha arm
 * configure           : alpha arm cris i386 lm32 m68k microblaze microblazeel mips mips64 mips64el mipsel moxie or32 ppc ppc64 ppcemb s390x sh4 sh4eb sparc sparc64 tricore unicore32 x86_64 xtensa xtensaeb aarch64
 * ERROR: app-emulation/qemu-2.4.0.1-r1::gentoo failed (prepare phase):
 *   sync IUSE_SOFTMMU_TARGETS to the list of targets
 * 
 * Call stack:
 *     ebuild.sh, line    90:  Called src_prepare
 *   environment, line 12474:  Called check_targets 'IUSE_SOFTMMU_TARGETS' 'softmmu'
 *   environment, line  8506:  Called die
 * The specific snippet of code:
 *           die "sync ${var} to the list of targets";
 * 
 * If you need support, post the output of `emerge --info '=app-emulation/qemu-2.4.0.1-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=app-emulation/qemu-2.4.0.1-r1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/work/qemu-2.4.0.1/default-configs'
 * S: '/var/tmp/portage/app-emulation/qemu-2.4.0.1-r1/work/qemu-2.4.0.1'

Expected Results:  
That it merges.

Nordic locales sorts "aa" after "z", because "aa" is an international/ascii-friendly way to write the letter "å". So if you make a function that compares two lists that are sorted alphabetically, you should force LC_ALL to be C to be sure it does not screw up in non-english locales.
Comment 1 SpanKY gentoo-dev 2015-11-06 16:33:52 UTC
i specifically wrote the sort code so that the locale it's run under should not matter.  i don't have a hardcoded list which is then compared against a locale sorted list ... both lists get run through `sort -u` which means the result should be the same.

sort is doing something weird here ... it's not stable when it sees aarch64.
$ printf '%s\n' aarch64 abc zed | LC_ALL=nb_NO.UTF-8 sort -u
aarch64
abc
zed
$ printf '%s\n' abc aarch64 zed | LC_ALL=nb_NO.UTF-8 sort -u
abc
zed
aarch64

i'll have to check with upstream to see if this behavior is correct.
Comment 2 Mads 2015-11-06 18:11:57 UTC
Why should it be stable?

I mean, in nordic locales it is correct that aa comes after z when sorting alphabetically (it's even like this in Windows). I couldn't find anything in the documentation to sort that tells that sorting alphabetically should be stable across locales...
Comment 3 Mads 2015-11-06 18:13:14 UTC
man sort states:

***  WARNING  ***  The locale specified by the environment affects sort
order.  Set LC_ALL=C to get the traditional sort order that uses native
byte values.
Comment 4 Mads 2015-11-06 18:15:54 UTC
Sorry for spamming the bug report, I didn't catch what you were complaining about after reading it over again several times.

Yes, I see what you mean now, it's kind of buggy that one list triggers aarch first and the another list triggers aarch last. That looks like a legitimate bug.

Should have read better, sorry.
Comment 5 SpanKY gentoo-dev 2015-11-06 22:09:28 UTC
looks like we're hitting a glibc bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=18589

which should be fixed in glibc-2.23.  i'll force LC_COLLATE=C in the mean time.