Bug 97508 - [10 Regression] ICE: decompressed stream: Destination buffer is too small
Summary: [10 Regression] ICE: decompressed stream: Destination buffer is too small
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: ice-on-valid-code, lto, patch
Depends on:
Blocks:
 
Reported: 2020-10-20 20:52 UTC by H.J. Lu
Modified: 2020-10-29 18:23 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 10.2.1, 11.0, 9.3.0
Known to fail:
Last reconfirmed: 2020-10-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2020-10-20 20:52:55 UTC
[hjl@gnu-skx-1 tmp]$ cat pr15323a.c
int main (void)
{
  return 0;
}
[hjl@gnu-skx-1 tmp]$ cat doit
CFLAGS="-flto -fno-profile-use -O2"
cc $CFLAGS -c pr15323a.c -o pr15323a.o
cc $CFLAGS -r -nostdlib pr15323a.o -o pr15323a-r.o
cc $CFLAGS  -o pr15323a.exe pr15323a-r.o
[hjl@gnu-skx-1 tmp]$ sh doit
during IPA pass: cp
lto1: internal compiler error: decompressed stream: Destination buffer is too small
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
lto-wrapper: fatal error: cc returned 1 exit status
compilation terminated.
/usr/local/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
[hjl@gnu-skx-1 tmp]$
Comment 1 Richard Biener 2020-10-21 06:13:40 UTC
It works for me.  What compression scheme are you using?  I have

Supported LTO compression algorithms: zlib

are you using zstd, if so, which version?
Comment 2 Martin Liška 2020-10-21 07:40:58 UTC
I can reproduce it, working on that..
Comment 3 Martin Liška 2020-10-21 08:04:02 UTC
Started with my r10-1548-g87741e51b53511be.
It's caused by the fact that .gnu.lto_.jmpfuncs.3f272ba23409d5d4 is streamed twise: from "cp" pass and then from "fnsummary" pass.
Comment 4 Martin Liška 2020-10-21 08:16:15 UTC
Then we end up with 2 copies of the compressed stream:

$ cat good.txt

y.o:     file format elf64-x86-64

Contents of section .gnu.lto_.jmpfuncs.c09bc76fb7147437:
 0000 28b52ffd 20116d00 00380500 01000000  (./. .m..8......
 0010 0001001b c002                        ......

$ cat bad.txt

y.o:     file format elf64-x86-64

Contents of section .gnu.lto_.jmpfuncs.9e830355985c8f8c:
 0000 28b52ffd 20116d00 00380500 01000000  (./. .m..8......
 0010 0001001b c00228b5 2ffd2011 6d000038  ......(./. .m..8
 0020 05000100 00000001 001bc002           ............    

Then we tell zstd section size and decompression fails as zstd frame header contains a smaller size.
Comment 5 GCC Commits 2020-10-29 13:33:09 UTC
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:568de14d2e74cfdd600b8995ff6ac08c98ddef48

commit r11-4526-g568de14d2e74cfdd600b8995ff6ac08c98ddef48
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Oct 21 11:11:03 2020 +0200

    LTO: get_section: add new argument
    
    gcc/ChangeLog:
    
            PR lto/97508
            * langhooks.c (lhd_begin_section): Call get_section with
            not_existing = true.
            * output.h (get_section): Add new argument.
            * varasm.c (get_section): Fail when NOT_EXISTING is true
            and a section already exists.
            * ipa-cp.c (ipcp_write_summary): Remove.
            (ipcp_read_summary): Likewise.
            * ipa-fnsummary.c (ipa_fn_summary_read): Always read jump
            functions summary.
            (ipa_fn_summary_write): Always stream it.
Comment 6 Martin Liška 2020-10-29 15:02:15 UTC
Fixed on master so far.
Comment 7 GCC Commits 2020-10-29 18:22:36 UTC
The releases/gcc-10 branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:32d16af0c4ede8d008d4360cca7c805db518166f

commit r10-8954-g32d16af0c4ede8d008d4360cca7c805db518166f
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Oct 21 11:11:03 2020 +0200

    LTO: get_section: add new argument
    
    gcc/ChangeLog:
    
            PR lto/97508
            * langhooks.c (lhd_begin_section): Call get_section with
            not_existing = true.
            * output.h (get_section): Add new argument.
            * varasm.c (get_section): Fail when NOT_EXISTING is true
            and a section already exists.
            * ipa-cp.c (ipcp_write_summary): Remove.
            (ipcp_read_summary): Likewise.
            * ipa-fnsummary.c (ipa_fn_summary_read): Always read jump
            functions summary.
            (ipa_fn_summary_write): Always stream it.
    
    (cherry picked from commit 568de14d2e74cfdd600b8995ff6ac08c98ddef48)
Comment 8 Martin Liška 2020-10-29 18:23:03 UTC
Fixed now.