develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Perl possible bugs with gcc 10, -O3 and unaligned long pointerderef

Thread Previous | Thread Next
Tony Cook
July 30, 2020 04:06
Re: Perl possible bugs with gcc 10, -O3 and unaligned long pointerderef
Message ID:
On Wed, Jul 29, 2020 at 10:17:26AM +0200, demerphq wrote:
> A bug was reported to the Sereal project which was traced to a change
> in behavior of gcc.
> The bug relates to unaligned pointer dereference operations which we
> do in Perl in certain places (hash engine in particular).
> We should probably look into testing perl with this:
> A known solution is to compile with -O2, or to use
> -fno-tree-loop-vectorize with -O3.
> >From the gcc bug report:
> "your unsigned long objects are not aligned according
> to the type which makes the accesses undefined (actually C even specifies
> forming the pointer itself is undefined)"
> I feel like we had a discussion about this recently and I argued this
> would never change, so I need to eat some crow.

In blead (and 5.32) the versions of the macros that try unaligned
access are guarded by C<#ifdef USE_UNALIGNED_PTR_DEREF> which perl
never defines itself.  See ed16b18d62c264e7e9331ea67931b66b7d976bb9
for that change and b8c77730539d8b2e48e6f7431c34b95ea893926b for the
merge where unaligned access was originally removed.

So it may be a problem in 5.30, but it's not a problem in 5.32 or
blead unless you explicitly request it.

IIRC the original issue was that compilers were optimizing the
original d_u32align probe on systems that don't allow unaligned access
to make it look like the system did support it.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About