Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

dev-lang/perl: fix segfault in perl-cross #19

Closed
wants to merge 1 commit into from

Conversation

dongsupark
Copy link
Contributor

In developer containers or SDK, there has been a bug in cross-compiled perl that it crashes with segmentation fault. It has two different reasons:

The first issue is that perl depends on perl-cross 1.1.4, which has a bug with gcc 7.x or newer, so that the necessary CFLAGS -fwrapv was not appended. This issue was fixed in perl-cross 1.1.9 or newer. So we just need to upgrade perl-cross to 1.2.2, the newest release.

  CROSS_VER=1.2.2

The other issue is that the CFLAGS -O2 was given when building cross-compiled perl. We should replace the optimization flag with -O0, when it's built by the cross compiler. Without that, the segfault will not be fixed at all.

  if tc-is-cross-compiler; then
      replace-flags -O? -O0
  fi

How to test inside the Flatcar SDK environment:

LD_PRELOAD=/build/amd64-usr/usr/lib/libperl.so.5.24.1 /build/amd64-usr/usr/bin/perl -V

See also coreos/bugs#2369
coreos/bugs#2545
arsv/perl-cross#60

In developer containers or SDK, there has been a bug in cross-compiled
perl that it crashes with segmentation fault. It has two different
reasons:

The first issue is that perl depends on perl-cross 1.1.4, which has a
bug with gcc 7.x or newer, so that the necessary CFLAGS `-fwrapv` was
not appended. This issue was fixed in perl-cross 1.1.9 or newer. So we
just need to upgrade perl-cross to 1.2.2, the newest release.

```
  CROSS_VER=1.2.2
```

The other issue is that the CFLAGS `-O2` was given when building
cross-compiled perl. We should replace the optimization flag with `-O0`,
when it's built by the cross compiler. Without that, the segfault will
not be fixed at all.

```
  if tc-is-cross-compiler; then
      replace-flags -O? -O0
  fi
```

How to test inside the Flatcar SDK environment:

```
LD_PRELOAD=/build/amd64-usr/usr/lib/libperl.so.5.24.1 /build/amd64-usr/usr/bin/perl -V
```

See also coreos/bugs#2369
coreos/bugs#2545
arsv/perl-cross#60
@dongsupark dongsupark added the bug Something isn't working label Feb 26, 2019
@dongsupark dongsupark self-assigned this Feb 26, 2019
@dongsupark dongsupark requested review from t-lo and iaguis February 26, 2019 14:10
@iaguis
Copy link
Contributor

iaguis commented Feb 26, 2019

Cool debugging!

Have you checked if updating to the latest upstream ebuilds and upgrading perl works? It seems perl 5.28.0 uses perl-cross 1.2.2 and that approach seems a bit cleaner to me than moving perl to coreos-overlay.

I also see that the current perl ebuild doesn't have the -O0 fix, so maybe upstream's ebuild doesn't work. In that case it'd be nice to contribute a fix upstream. What do you think?

Related: gentoo/gentoo#10976

@dongsupark
Copy link
Contributor Author

I've already tried to upgrade perl to 5.26.
I didn't work well, because so many other perl packages depend on the exact version of perl, 5.24.1-r2. Updating all of these would make this PR much bigger.
I just wanted to fix only the particular issues without touching other parts.

@dongsupark
Copy link
Contributor Author

Filed a PR against upstream Gentoo, to turn off -O? options. gentoo/gentoo#11171

On the other hand, upstream Container Linux already includes a recent version of perl 5.26.2 with keyword amd64 with CROSS_VER=1.1.9, while the ebuild in our flatcar-master branch still stays with keyword ~amd64.

So it would be a better approach to simply merge upstream master into flatcar-master, without changing downstream perl. I'm not sure what that change would suddenly break other builds. Anyway the critical releases were just gone, so it might be a good moment to be in sync with upstream, right? :-)

@dongsupark
Copy link
Contributor Author

So I created 2 draft PRs that merge upstream into flatcar-master, and update perl packages.

With the 2 PRs, we can build an image with perl 5.26.2. On top of that, if the upstream Gentoo PR got merged, it's possible to fix the segfault issue.

Unfortunately It's not possible to avoid downstream changes completely. Some perl packages still rely on old version of perl.

So I'm not sure if that's a better approach.

@dongsupark
Copy link
Contributor Author

Not needed any more.

@dongsupark dongsupark closed this Apr 17, 2019
@dongsupark dongsupark deleted the dongsu/fix-perl-segfault branch April 17, 2019 09:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants