Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 672032

Summary: >=sys-devel/gcc-7.4.0: internal compiler error: Segmentation fault when building net-analyzer/netcat-110-r9
Product: Gentoo Linux Reporter: ernsteiswuerfel <erhard_f>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: netmon, slyfox, toolchain
Priority: Normal    
Version: unspecified   
Hardware: PPC   
OS: Linux   
URL: https://gcc.gnu.org/PR88214
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88214
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: build.log
build-dir.tar.xz
emerge --info
nc.i
nc.c

Description ernsteiswuerfel archtester 2018-11-26 21:25:41 UTC
Created attachment 556422 [details]
build.log

[...]
netcat.c:2367:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 helpme()
 ^~~~~~
netcat.c: In function ‘atelnet’:
netcat.c:1641:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
       (void) write (netfd, obuf, 3);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
netcat.c: In function ‘doconnect’:
netcat.c:2419:1: internal compiler error: Segmentation fault
 } /* helpme */
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.
make: *** [Makefile:31: nc] Error 1
Comment 1 ernsteiswuerfel archtester 2018-11-26 21:26:29 UTC
Created attachment 556424 [details]
build-dir.tar.xz
Comment 2 ernsteiswuerfel archtester 2018-11-26 21:27:28 UTC
Created attachment 556426 [details]
emerge --info
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2018-11-26 21:56:12 UTC
Is that a reproducible problem or a one-off?
Comment 4 ernsteiswuerfel archtester 2018-11-26 23:49:14 UTC
(In reply to Jeroen Roovers from comment #3)
> Is that a reproducible problem or a one-off?

Yes, this is reproducible.

Had a chat with slyfox on #gentoo-powerpc who suggested to try different gcc-versions:

gcc-6.4.0-r5: success
gcc-7.3.0-r3: failure
gcc-8.2.0-r4: failure
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2018-11-26 23:54:29 UTC
Created attachment 556432 [details]
nc.i
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2018-11-26 23:56:18 UTC
(In reply to Sergei Trofimovich from comment #5)
> Created attachment 556432 [details]
> nc.i

That seems to be enough to chars gcc on timberdoodle on 32-bit UL as:
    $ LANG=C powerpc-unknown-linux-gnu-gcc -O2 -mcpu=powerpc -pipe -o nc.i -c nc.c
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2018-11-27 00:05:19 UTC
(In reply to Sergei Trofimovich from comment #6)
> (In reply to Sergei Trofimovich from comment #5)
> > Created attachment 556432 [details]
> > nc.i
> 
> That seems to be enough to chars gcc on timberdoodle on 32-bit UL as:
>     $ LANG=C powerpc-unknown-linux-gnu-gcc -O2 -mcpu=powerpc -pipe -o nc.i
> -c nc.c

Fun fact: sparc32 also SIGSEGVs on that example:
    $ LANG=C sparc-unknown-linux-gnu-gcc-7.3.0 -O2 -pipe -c nc.i -o nc.o

  nc.i:44:3915: internal compiler error: Segmentation fault
   _timer (1, o_wait);   if (      __sigsetjmp (

My guess it's a pointer size bug in gcc-7. Let's try to sort it on on toolchain@ side first.
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2018-11-27 09:05:45 UTC
Created attachment 556442 [details]
nc.c

Shorter example:

  $ cat nc.c
  void i();
  short a;
  void b(e) char * e;
  {
    i();
    b(a);
  }


  $ LANG=C sparc-unknown-linux-gnu-gcc-7.3.0 -Wall -O2 -pipe -o nc.o -c nc.c
  nc.c: In function 'b':
  nc.c:7:1: internal compiler error: Segmentation fault

  $ LANG=C powerpc-unknown-linux-gnu-gcc -Wall -O2 -pipe -o nc.o -c nc.c
  nc.c: In function 'b':
  nc.c:7:1: internal compiler error: Segmentation fault

Note: it seems to be triggered by K&R-style function declarations.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2018-11-27 09:15:10 UTC
Moving discussion to upstream bugtracker:
    https://gcc.gnu.org/PR88214
Comment 10 Sergei Trofimovich (RETIRED) gentoo-dev 2018-12-10 22:50:23 UTC
Queued for the next 8.2.0 and 7.4.0 gcc patchsets as:
    https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=44f5a4b4d1884a2646f77195c172fe8065295d1d
    https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ef2a97ee34b85bfb7865ce9d78d28b4a31294706

Meanwhile you can drop a patch to /etc/portage/patches/sys-devel/gcc/ and see if it works for you.
Comment 11 ernsteiswuerfel archtester 2018-12-11 22:19:50 UTC
Yes, I can confirm it builds fine now with gcc-7.4.0 + patch. Thanks!
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2018-12-11 23:06:46 UTC
Thank you for testing!
Comment 13 Larry the Git Cow gentoo-dev 2018-12-26 19:40:12 UTC
The bug has been referenced in the following commit(s):

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

commit d27b9469785e09efe5e808af0dfbf7eebdeaf627
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-12-26 19:37:14 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-12-26 19:39:59 +0000

    sys-devel/gcc: bump up to 1.7 patchset
    
    Two new patches:
    + 114_all_kr-decl-PR88214.patch: ICE on k&r declarations
    + 115_all_avx2-SIGSEGV-PR86871.patch: ICE in vectorizer
    
    Bug: https://bugs.gentoo.org/672032
    Bug: https://bugs.gentoo.org/657060
    Package-Manager: Portage-2.3.52, Repoman-2.3.12
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/gcc/Manifest            |  1 +
 sys-devel/gcc/gcc-8.2.0-r6.ebuild | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
Comment 14 Joakim Tjernlund 2018-12-31 13:59:23 UTC
Only gcc 8.2 patched? What about gcc 7.4 ?
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2018-12-31 14:12:45 UTC
patch for 7.4.0 was queued in #c10 but did not get to patchset release yet.
Comment 16 Larry the Git Cow gentoo-dev 2019-02-09 16:38:44 UTC
The bug has been closed via the following commit(s):

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

commit d397de260edea710cd2452005473a440cbb79699
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-02-09 12:16:36 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-02-09 16:38:28 +0000

    sys-devel/gcc: cut 1.2 patchset for 7.4.0
    
    One new patch and one update:
    U 01_all_default-fortify-source.patch: make _FORTIFY_SOURCE portable
    + 21_all_kr-decl-PR88214.patch: fix SIGSEVs on net-analyzer/netcat
    
    Reported-by: ernsteiswuerfel
    Closes: https://bugs.gentoo.org/672032
    Reported-and-tested-by:  Martin Kletzander
    Tested-by: Tomáš Mózes
    Bug: https://bugs.gentoo.org/621036
    Package-Manager: Portage-2.3.59, Repoman-2.3.12
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/gcc/Manifest            |  1 +
 sys-devel/gcc/gcc-7.4.0-r1.ebuild | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)