Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 877659 - dev-lang/perl-5.34.1-r3: build issue
Summary: dev-lang/perl-5.34.1-r3: build issue
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Perl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-19 15:17 UTC by Jocelyn Mayer
Modified: 2022-10-28 12:37 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Build log for the "S0" server (S0_perl-5.34.1-r3:20221001-071921.log,86.74 KB, text/plain)
2022-10-19 15:19 UTC, Jocelyn Mayer
Details
output from emerge --info ==dev-lang/perl-5.34.1-r3 on "S0" server (S0-perl_infos,21.91 KB, text/plain)
2022-10-19 15:20 UTC, Jocelyn Mayer
Details
Build log for the "S1" server (S1-perl-5.34.1-r3:20221001-053006.log,100.99 KB, text/plain)
2022-10-19 15:21 UTC, Jocelyn Mayer
Details
Output from emerge --info =dev-lang/perl-5.34.1-r3 on "S1" server (S1-perl_infos,23.32 KB, text/plain)
2022-10-19 15:23 UTC, Jocelyn Mayer
Details
Build log for the laptop (perl-5.34.1-r3:20220924-055601.log,144.75 KB, text/x-log)
2022-10-19 15:25 UTC, Jocelyn Mayer
Details
Output from emerge --info =dev-lang/perl-5.34.1-r3 on the laptop (perl-infos,35.80 KB, text/plain)
2022-10-19 15:26 UTC, Jocelyn Mayer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jocelyn Mayer 2022-10-19 15:17:49 UTC
the build on this dev-lang/perl version fails on all my systems while launching miniperl which stops with the message:
Attempt to free unreferenced scalar: SV 0x561970a28330 at lib/strict.pm

Reproducible: Always

Steps to Reproduce:
1. Try to build dev-lang/perl-5.34.1-r3
2. Wait for the sentence
3.
Actual Results:  
Build fails

Expected Results:  
Build should succeed

I'm not used with perl, thus I don't feel like investigating about this problem.
As it seems that nobody have seen this bug before, it may be due to some global system configurations like hardening (on servers), kernel random memory mapping, or anything else...
Following the logs for 3 systems: 
S0: online server, hardened, minimal configuration with lots of security features
S1: local server, hardened, with more enabled features / software than S0
other: a laptop, not hardened with a lot of software installed
Comment 1 Jocelyn Mayer 2022-10-19 15:19:45 UTC
Created attachment 824755 [details]
Build log for the "S0" server
Comment 2 Jocelyn Mayer 2022-10-19 15:20:32 UTC
Created attachment 824757 [details]
output from emerge --info ==dev-lang/perl-5.34.1-r3 on "S0" server
Comment 3 Jocelyn Mayer 2022-10-19 15:21:33 UTC
Created attachment 824759 [details]
Build log for the "S1" server
Comment 4 Jocelyn Mayer 2022-10-19 15:23:04 UTC
Created attachment 824761 [details]
Output from emerge --info =dev-lang/perl-5.34.1-r3 on "S1" server
Comment 5 Jocelyn Mayer 2022-10-19 15:25:50 UTC
Created attachment 824763 [details]
Build log for the laptop
Comment 6 Jocelyn Mayer 2022-10-19 15:26:39 UTC
Created attachment 824765 [details]
Output from emerge --info =dev-lang/perl-5.34.1-r3 on the laptop
Comment 7 Jocelyn Mayer 2022-10-19 15:29:21 UTC
Note that I did took emerge --info for a previous version for the laptop because it seems that when the package did not merge we don't have the packages settings at the end of the log
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-10-28 07:07:15 UTC
My bet is this is somehow related to bug 821577, i.e. the -fno-strict-aliasing is getting dropped somewhere.

Is that enough of a hint for now for you to poke at it more? I don't have time atm unfortunately.
Comment 9 Jocelyn Mayer 2022-10-28 08:57:05 UTC
(In reply to Sam James from comment #8)
> My bet is this is somehow related to bug 821577, i.e. the
> -fno-strict-aliasing is getting dropped somewhere.
> 
> Is that enough of a hint for now for you to poke at it more? I don't have
> time atm unfortunately.

You're right, it seems to be the exact same bug with the only difference as I don't get a segfault after the crash.
I will try to investigate the build flags, as you suggest, thanks !
Comment 10 Jocelyn Mayer 2022-10-28 12:22:43 UTC
(In reply to Jocelyn Mayer from comment #9)
> (In reply to Sam James from comment #8)
> > My bet is this is somehow related to bug 821577, i.e. the
> > -fno-strict-aliasing is getting dropped somewhere.
> > 
> > Is that enough of a hint for now for you to poke at it more? I don't have
> > time atm unfortunately.
> 
> You're right, it seems to be the exact same bug with the only difference as
> I don't get a segfault after the crash.
> I will try to investigate the build flags, as you suggest, thanks !

I can confirm that the problem is due to strict aliasing issue.
The '-fno-strict-aliasing' flag is not dropped by the build system but I don't enable it as global compilation flag.
Forcing it to be used (using a dedicated /etc/portage/env file) made me able to build dev-lang/perl on 5 different systems with different configurations (hardened enabled / disabled, lto en / dis, ...), all amd64 based. It seems that test would failed at least for some configuration but I did not investigate this.
I noticed that there still are numerous compilation warnings about potential undefinied behavior including, but not only, code like : s += SOMETHING(s);

For the issue I reported, forcing fno-strict-aliasing in the ebuild seems to me to be a reasonable fix.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-10-28 12:26:25 UTC
(In reply to Jocelyn Mayer from comment #10)
> (In reply to Jocelyn Mayer from comment #9)
> > (In reply to Sam James from comment #8)
> > > My bet is this is somehow related to bug 821577, i.e. the
> > > -fno-strict-aliasing is getting dropped somewhere.
> > > 
> > > Is that enough of a hint for now for you to poke at it more? I don't have
> > > time atm unfortunately.
> > 
> > You're right, it seems to be the exact same bug with the only difference as
> > I don't get a segfault after the crash.
> > I will try to investigate the build flags, as you suggest, thanks !
> 
> I can confirm that the problem is due to strict aliasing issue.
> The '-fno-strict-aliasing' flag is not dropped by the build system but I
> don't enable it as global compilation flag.

The weird thing is it's enabled by -O2. I was suspicious that perhaps your(?) "-Wstrict-aliasing" was confusing the (very weird) Perl build system (maybe it greps for "strict-aliasing" and then skips addint -fno-strict-aliasing if present).

> Forcing it to be used (using a dedicated /etc/portage/env file) made me able
> to build dev-lang/perl on 5 different systems with different configurations
> (hardened enabled / disabled, lto en / dis, ...), all amd64 based. It seems
> that test would failed at least for some configuration but I did not
> investigate this.

Fantastic! Yeah, it's obviously failing for some weird reason.

> I noticed that there still are numerous compilation warnings about potential
> undefinied behavior including, but not only, code like : s += SOMETHING(s);
> 
> For the issue I reported, forcing fno-strict-aliasing in the ebuild seems to
> me to be a reasonable fix.

Given this is the second time it's come up, I agree, let's just bung it in append-flags.
Comment 12 Larry the Git Cow gentoo-dev 2022-10-28 12:37:52 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=28d674673b7e0198d2770ec5a780966555dbbc6a

commit 28d674673b7e0198d2770ec5a780966555dbbc6a
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-10-28 12:36:37 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-10-28 12:37:31 +0000

    dev-lang/perl: always pass -fno-strict-aliasing
    
    We keep getting these bugs where it turns out the build system
    didn't pass it for us, so just unconditionally do it.
    
    Closes: https://bugs.gentoo.org/877659
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-lang/perl/{perl-5.34.1-r3.ebuild => perl-5.34.1-r4.ebuild} | 5 ++++-
 dev-lang/perl/{perl-5.36.0.ebuild => perl-5.36.0-r1.ebuild}    | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)