This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] libio: Add small optimization on fmemopen
On 21/09/2016 16:27, Florian Weimer wrote:
> On 09/21/2016 08:57 PM, Paul Eggert wrote:
>> On 09/21/2016 11:47 AM, Florian Weimer wrote:
>>> We don't know the nature of the GCC issue, so we cannot work around it
>>> reliably. The most likely explanation is that Address Sanitizer does
>>> not account for a valid GCC optimization.
>>
>> That's not the sense that I get from looking at Bug 66661. GCC is
>> assuming it can do an aligned word load of the trailing bytes of a
>> flexible array member in a properly-aligned structure.
>
> But that assumption is completely correct! It's just that Address Sanitizer does not account for it (based on what I've seen so far).
>
>> Although the followups to Bug 66661 suggest that there may be
>> further problems with overaligned structures, the code here is not using
>> _Alignas so these further problems are not an issue here.
>
> _Alignas is used only to demonstrate the issue more clearly.
>
> glibc currently does not compile with Address Sanitizer anyway, so until that is fixed (or someone has a better explanation of the root cause of GCC PR66661), I would suggest to assume that this issue does not matter to glibc at all.
I check with a different memory profiler (valgrind) and at least with gcc 5.4
fmemopen with this change shows no wrong memory access. It also shows that
the issue might be indeed in ASAN.
I think we can push this optimization as if and I will continue track BZ#66661
to check for further development if the patch would require more changes.