Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 708744 - =dev-lang/perl-5.30.1 crashes on gcc-10: Attempt to free unreferenced scalar: SV 0x........
Summary: =dev-lang/perl-5.30.1 crashes on gcc-10: Attempt to free unreferenced scalar:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Perl team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2020-02-08 19:09 UTC by Sergei Trofimovich (RETIRED)
Modified: 2020-03-21 23:22 UTC (History)
0 users

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


Attachments
perl-5-gcc-10.patch (perl-5-gcc-10.patch,2.89 KB, patch)
2020-02-08 19:23 UTC, Sergei Trofimovich (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-08 19:09:49 UTC
The build fails early as:

"""
x86_64-pc-linux-gnu-gcc -c -DPERL_CORE -fwrapv -fpcc-struct-return -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -march=sandybridge -mtune=sandybridge -maes --param=l1-cache-size=32 --param=l1-cache-line-size=64 --param=l2-cache-size=8192 -O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches -Wall -Wextra -Wstack-protector -g -Wall -fPIC gv.c
...
LD_LIBRARY_PATH=/tmp/portage/dev-lang/perl-5.30.1/work/perl-5.30.1 /tmp/portage/dev-lang/perl-5.30.1/work/perl-5.30.1/preload /tmp/portage/dev-lang/perl-5.30.1/work/perl-5.30.1/libperl.so.5.30.1 ./miniperl -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
Attempt to free unreferenced scalar: SV 0x5555ed3e1378.
/bin/sh: line 1: 4057907 Segmentation fault      (core dumped) LD_LIBRARY_PATH=/tmp/portage/dev-lang/perl-5.30.1/work/perl-5.30.1 /tmp/portage/dev-lang/perl-5.30.1/work/perl-5.30.1/preload /tmp/portage/dev-lang/perl-5.30.1/work/perl-5.30.1/libperl.so.5.30.1 ./miniperl -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>'
"""

Note how x86_64-pc-linux-gnu-gcc command lacks a few crucial flags and adds ancient ones. Here is 9.2.0 build command for comparison:

"""
x86_64-pc-linux-gnu-gcc-9.2.0 -c -DPERL_CORE -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -std=c89 -march=sandybridge -mtune=sandybridge -maes --param=l1-cache-size=32 --param=l1-cache-line-size=64 --param=l2-cache-size=8192 -O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches -Wall -Wextra -Wstack-protector -g -Wall -Werror=declaration-after-statement -Werror=pointer-arith -Wextra -Wc++-compat -Wwrite-strings -fPIC gv.c
"""

Specifically on gcc-10:
- -fpcc-struct-return is passed: that breaks struct-passing ABI
- -fno-strict-aliasing is not passed: that makes type punning code to throw away "dead" loads/stores across ponter casts.


The bug is already fixed upstream in
    https://github.com/Perl/perl5/commit/6bd6308fcea3541e505651bf8e8127a4a03d22cd
where gcc-10 was detected as gcc-1.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-08 19:23:42 UTC
Created attachment 612830 [details, diff]
perl-5-gcc-10.patch

perl-5-gcc-10.patch fixes perl for me. Note: it's an upstream patch with a tiny change: accidental gcc version "detection" change is reverted.
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-13 22:19:08 UTC
(In reply to Sergei Trofimovich from comment #1)
> Created attachment 612830 [details, diff] [details, diff]
> perl-5-gcc-10.patch
> 
> perl-5-gcc-10.patch fixes perl for me. Note: it's an upstream patch with a
> tiny change: accidental gcc version "detection" change is reverted.

A month has passed. I plan to go ahead and apply it in a few days to stable ebuild as:

--- a/dev-lang/perl/perl-5.30.1.ebuild
+++ b/dev-lang/perl/perl-5.30.1.ebuild
@@ -304,6 +304,7 @@ src_prepare() {
 	if use hppa ; then
 		epatch "${FILESDIR}/${PN}-5.26.2-hppa.patch" # bug 634162
 	fi
+	eapply "${FILESDIR}"/${PN}-5.30.1-gcc-10.patch # bug 708744

 	if [[ ${CHOST} == *-solaris* ]] ; then
 		# do NOT mess with nsl, on Solaris this is always necessary,
Comment 3 Larry the Git Cow gentoo-dev 2020-03-21 22:59:52 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3f58732f2213d0453bbbe165c4f08694b3653df7

commit 3f58732f2213d0453bbbe165c4f08694b3653df7
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-03-21 22:56:19 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-03-21 22:59:45 +0000

    dev-lang/perl: tweak for gcc-10, bug #708744
    
    Perl's Configure detected gcc-10 as gcc-1 and applied
    -fpcc-struct-return option that breakw C ABI. This caused
    mini-interpreter to crash early at bootstrap time.
    
    The change is a direct backport of upstreams
    6bd6308fcea3541e50565 ("Adapt Configure to GCC version 10").
    
    Closes: https://bugs.gentoo.org/708744
    Package-Manager: Portage-2.3.94, Repoman-2.3.21
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 dev-lang/perl/files/perl-5.30.1-gcc-10.patch | 99 ++++++++++++++++++++++++++++
 dev-lang/perl/perl-5.30.1.ebuild             |  1 +
 2 files changed, 100 insertions(+)