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

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

Thread Previous
From:
Leon Timmermans
Date:
July 29, 2020 17:24
Subject:
Re: Perl possible bugs with gcc 10, -O3 and unaligned long pointerderef
Message ID:
CAHhgV8jMgFC=xTs8zPcmtnxnuyaFyNg8T+U2Uz98WF-T8OCaCA@mail.gmail.com
On Wed, Jul 29, 2020 at 10:17 AM demerphq <demerphq@gmail.com> wrote:

> 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.
>

Wouldn't such code already be problematic on architectures with strict
alignment requirements? (e.g. SPARC) And hence we should have noticed
already if we have such a problem?

Leon

Thread Previous


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