Bug 247738 - on powerpc64 bc exits with segfault right after starting it
Summary: on powerpc64 bc exits with segfault right after starting it
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: powerpc Any
: --- Affects Many People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-03 12:22 UTC by Piotr Kubaj
Modified: 2020-07-25 23:54 UTC (History)
7 users (show)

See Also:


Attachments
Disable -flto on powerpc64 (557 bytes, patch)
2020-07-03 19:56 UTC, Leandro Lupori
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer freebsd_triage 2020-07-03 12:22:08 UTC
I use head on powerpc64, r362833.

Running bc causes a segfault.

pkubaj@talos:$~$ bc
Segmentation fault (core dumped)

(gdb) run
Starting program: /usr/bin/bc

Program received signal SIGSEGV, Segmentation fault.
0x0000000010068450 in main ()
(gdb) bt
#0  0x0000000010068450 in main ()
#1  0x0000000010018e80 in _start (argc=<optimized out>, argv=0xfffffbfffe988, env=<optimized out>, obj=<optimized out>, cleanup=<optimized out>, ps_strings=<optimized out>)
    at /usr/src/lib/csu/powerpc64/crt1_c.c:127
Comment 1 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-03 12:23:16 UTC
Adding se@, who committed bc.
Comment 2 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-03 12:29:36 UTC
Also adding imp@, who accepted https://reviews.freebsd.org/D19982.
Comment 3 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-03 17:03:29 UTC
This bug causes Poudriere to segfault during build (because Poudriere uses bc). As such, clusteradm@ must NOT upgrade powerpc64/head systems with new bc until this is fixed, because this will break repo building.

Adding clusteradm@ so that they can keep track of this issue.
Comment 4 Li-Wen Hsu freebsd_committer freebsd_triage 2020-07-03 17:13:41 UTC
(In reply to Piotr Kubaj from comment #3)
To make it clear, do you mean the powerpc64 package builder should stay as it as for now and shouldn't be upgraded?

BTW, package builder's base version is controlled by portmgr team.
Comment 5 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-03 17:18:15 UTC
(In reply to Li-Wen Hsu from comment #4)
Yes, I meant the host (not Poudriere jails) because this issue directly affects Poudriere.

Poudriere jails can probably be upgraded, just some ports that use bc to build will fail.

I thought portmgr@ controlled only jails, while clusteradm@ managed hosts. Is that not the case?
Comment 6 Li-Wen Hsu freebsd_committer freebsd_triage 2020-07-03 17:22:05 UTC
(In reply to Piotr Kubaj from comment #5)
Thanks for clarification. clusteradm build the base images for different branches and versions for the cluster. portmgr have root on the machines allocated for them, and they decide when and what to install/upgrade is the best.
Comment 7 Leandro Lupori freebsd_committer freebsd_triage 2020-07-03 19:56:47 UTC
Created attachment 216180 [details]
Disable -flto on powerpc64

The attached patch fixes the issue for me.

There is probably a bug with LLVM's LTO for PowerPC64 (but, at least on PPC64, it doesn't seem related to floating point incompatibilities, as a comment in the Makefile suggests).

It is probably worth to investigate why LLVM LTO is producing incorrect code, but disabling LTO for gh-bc should be fine while LLVM is not fixed (if this is really the case).

For the record, the code fragment that is crashing is jumping to a pointer to a TOC entry, instead of using the pointer stored at that TOC entry, that correctly points to main().
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-07-03 20:33:39 UTC
A commit references this bug:

Author: emaste
Date: Fri Jul  3 20:32:54 UTC 2020
New revision: 362914
URL: https://svnweb.freebsd.org/changeset/base/362914

Log:
  bc: disable -flto on powerpc64

  Previously bc segfaulted at start, on powerpc64.

  PR:		247738
  Submitted by:	luporl
  Reported by:	pkubaj
  MFC after:	1 week

Changes:
  head/usr.bin/gh-bc/Makefile
Comment 9 Mark Linimon freebsd_committer freebsd_triage 2020-07-25 23:54:22 UTC
^Triage: assign to committer that resolved.