[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25024: Bug in Sort

From: Pádraig Brady
Subject: bug#25024: Bug in Sort
Date: Fri, 25 Nov 2016 22:25:26 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 25/11/16 18:50, Paul Eggert wrote:
> Pádraig Brady wrote:
>> for UBSAN we should probably build with
>> _STRING_ARCH_unaligned defined globally
>> to avoid warning for the cases we already handle.
> Yes. Translating this for non-experts: the problem here is a bug in the 
> bug-finding procedure, not a bug in GNU coreutils or in Gnulib.

Sorry I was a bit terse. coreutils/gnulib should currently be compiled with
  -D_STRING_ARCH_unaligned=0 -D_STRING_INLINE_unaligned=0
when using UBSAN, to use only alignment portable code.
Methods for avoiding false UBSAN warnings automatically are discussed below...

> Recent glibc (since 2016-02-18) does not define _STRING_ARCH_unaligned, which 
> means that this code in gnulib md5.c etc. is no longer exercised on recent 
> platforms.

Oh interesting. I see details in:
There it suggests that _STRING_ARCH_unaligned is now internal
to glibc and _STRING_INLINE_unaligned is the newer stable equivalent.
Attached patch to do this for coreutils is attached.

> So in some sense the originally-reported bug is already fixed (via an 
> unexpected glibc change), though this does mean Gnulib md5 etc. is now slower 
> on 
> x86-64 etc., which is a performance bug on newer platforms. If we fix the 
> performance bug I suppose we'll start getting false alarms from UBSAN again.

We can explicitly avoid the UBSAN warnings with something like:
which might be acceptable given the few places it matters.
That's a bit of a big hammer though, defining away all of UBSAN for those 

Alternatively we might define the non-portable faster path away,
if we could detect we where compiling in UBSAN mode.
That's easy enough for -fsanitize=address, though it doesn't
look like there is currently a way to detect -fsanitize=undefined?

Another approach would be to support ../configure --with-asan --with-ubsan
which would define things appropriately.


Attachment: coreutils-unaligned.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]