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

Perl possible bugs with gcc 10, -O3 and unaligned long pointer deref

Thread Next
From:
demerphq
Date:
July 29, 2020 08:17
Subject:
Perl possible bugs with gcc 10, -O3 and unaligned long pointer deref
Message ID:
CANgJU+UHf2Fh+9xUBECQKt7i0veXMa4Jxev9etdZU_3uvyERFg@mail.gmail.com
A bug was reported to the Sereal project which was traced to a change
in behavior of gcc.

https://github.com/Sereal/Sereal/issues/229

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96326

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:

https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

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.

cheers,
Yves




-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About