public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/107592] New: ICE: gdc segfault on label continue
@ 2022-11-09 16:06 zorael at gmail dot com
  2022-11-09 17:32 ` [Bug d/107592] " ibuclaw at gdcproject dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zorael at gmail dot com @ 2022-11-09 16:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

            Bug ID: 107592
           Summary: ICE: gdc segfault on label continue
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: zorael at gmail dot com
  Target Milestone: ---

Manjaro/Arch x86_64, gdc from gcc-d 12.2.0-1 from official repositories.

The following code ICEs with a segmentation fault.

```
void main()
{
    foo(string.init);
}

void foo(Things...)(Things things)
{
    label:
    foreach (thing; things)
    {
        continue label;
    }
}
```

`gdc -v -save-temps -freport-bug app.d` output:

```
Using built-in specs.
COLLECT_GCC=gdc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-o' 'a.out'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/d21 app.d -quiet -dumpdir a- -dumpbase
app.d -dumpbase-ext .d -mtune=generic -march=x86-64 -version -freport-bug -v -o
a-app.s
GNU D (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU D (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
binary    /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/d21
version   v2.100.1

predefs   GNU D_Version2 LittleEndian GNU_DWARF2_Exceptions GNU_StackGrowsDown
GNU_InlineAsm D_LP64 D_PIC D_PIE assert D_PreConditions D_PostConditions
D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo all X86_64 D_HardFloat Posix
linux CRuntime_Glibc CppRuntime_Gcc
parse     app
importall app
import    object       
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/object.d)
import    core.attribute       
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/attribute.d)
import    gcc.attributes       
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/gcc/attributes.d)
import    core.internal.hash   
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/hash.d)
import    core.internal.traits 
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/traits.d)
import    core.internal.entrypoint     
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/entrypoint.d)
import    core.internal.array.appending
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/appending.d)
import    core.internal.array.comparison       
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/comparison.d)
import    core.internal.array.equality 
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/equality.d)
import    core.internal.array.casting  
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/casting.d)
import    core.internal.array.concatenation    
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/concatenation.d)
import    core.internal.array.construction     
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/construction.d)
import    core.internal.array.capacity 
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/array/capacity.d)
import    core.internal.dassert
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/dassert.d)
import    core.atomic  
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/atomic.d)
import    core.internal.attributes     
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/attributes.d)
import    core.internal.atomic 
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/atomic.d)
import    gcc.builtins 
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/gcc/builtins.d)
import    gcc.config   
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/gcc/config.d)
import    core.internal.destruction    
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/destruction.d)
import    core.internal.moving 
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/moving.d)
import    core.internal.postblit       
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/postblit.d)
import    core.internal.switch_
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/internal/switch_.d)
import    core.lifetime
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/lifetime.d)
import    core.builtins
(/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/core/builtins.d)
semantic  app
entry     main  app.d
semantic2 app
semantic3 app
code      app
function  D main
function  app._d_cmain!().main
function  app.foo!string.foo
during GIMPLE pass: cfg
app.d: In function ‘foo’:
app.d:6:6: internal compiler error: Segmentation fault
    6 | void foo(Things...)(Things things)
      |      ^
0x1ac32f4 internal_error(char const*, ...)
        ???:0
0xe98543 cleanup_dead_labels()
        ???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/107592] ICE: gdc segfault on label continue
  2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
@ 2022-11-09 17:32 ` ibuclaw at gdcproject dot org
  2022-11-30 17:10 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-11-09 17:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Generated function:
---
void foo (struct  _param_0)
{
  void label = <<< error >>>;

  label:;
  while (1)
    {
      {
        struct  thing;

        thing = _param_0;
        goto <D.1797>;
      }
      goto <D.1796>;
    }
  <D.1796>:;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/107592] ICE: gdc segfault on label continue
  2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
  2022-11-09 17:32 ` [Bug d/107592] " ibuclaw at gdcproject dot org
@ 2022-11-30 17:10 ` cvs-commit at gcc dot gnu.org
  2022-11-30 21:01 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-30 17:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:031d3f095520f0e1ee03e29b7ad5067c2a3f96e0

commit r13-4413-g031d3f095520f0e1ee03e29b7ad5067c2a3f96e0
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Nov 12 00:54:47 2022 +0100

    d: Fix ICE on named continue label in an unrolled loop [PR107592]

    Continue labels in an unrolled loop require a unique label per
    iteration.  Previously this used the Statement body node for each
    unrolled iteration to generate a new entry in the label hash table.
    This does not work when the continue label has an identifier, as said
    named label is pointing to the outer UnrolledLoopStatement node.

    What would happen is that during the lowering of `continue label', an
    automatic label associated with the unrolled loop would be generated,
    and a jump to that label inserted, but because it was never pushed by
    the visitor for the loop itself, it subsequently never gets emitted.

    To fix, correctly use the UnrolledLoopStatement as the key to look up
    and store the break/continue label pair, but remove the continue label
    from the value entry after every loop to force a new label to be
    generated by the next call to `push_continue_label'

            PR d/107592

    gcc/d/ChangeLog:

            * toir.cc (IRVisitor::push_unrolled_continue_label): New method.
            (IRVisitor::pop_unrolled_continue_label): New method.
            (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of
            push_continue_label and pop_continue_label.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr107592.d: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/107592] ICE: gdc segfault on label continue
  2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
  2022-11-09 17:32 ` [Bug d/107592] " ibuclaw at gdcproject dot org
  2022-11-30 17:10 ` cvs-commit at gcc dot gnu.org
@ 2022-11-30 21:01 ` cvs-commit at gcc dot gnu.org
  2022-11-30 21:03 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-30 21:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:2909464c405b79559c5507cde382df05d2d2fa41

commit r12-8951-g2909464c405b79559c5507cde382df05d2d2fa41
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Nov 12 00:54:47 2022 +0100

    d: Fix ICE on named continue label in an unrolled loop [PR107592]

    Continue labels in an unrolled loop require a unique label per
    iteration.  Previously this used the Statement body node for each
    unrolled iteration to generate a new entry in the label hash table.
    This does not work when the continue label has an identifier, as said
    named label is pointing to the outer UnrolledLoopStatement node.

    What would happen is that during the lowering of `continue label', an
    automatic label associated with the unrolled loop would be generated,
    and a jump to that label inserted, but because it was never pushed by
    the visitor for the loop itself, it subsequently never gets emitted.

    To fix, correctly use the UnrolledLoopStatement as the key to look up
    and store the break/continue label pair, but remove the continue label
    from the value entry after every loop to force a new label to be
    generated by the next call to `push_continue_label'

            PR d/107592

    gcc/d/ChangeLog:

            * toir.cc (IRVisitor::push_unrolled_continue_label): New method.
            (IRVisitor::pop_unrolled_continue_label): New method.
            (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of
            push_continue_label and pop_continue_label.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr107592.d: New test.

    (cherry picked from commit 031d3f095520f0e1ee03e29b7ad5067c2a3f96e0)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/107592] ICE: gdc segfault on label continue
  2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
                   ` (2 preceding siblings ...)
  2022-11-30 21:01 ` cvs-commit at gcc dot gnu.org
@ 2022-11-30 21:03 ` cvs-commit at gcc dot gnu.org
  2022-11-30 21:05 ` cvs-commit at gcc dot gnu.org
  2022-11-30 21:10 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-30 21:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:7bb5b326796af7d688c9976fba7ba3c2706481a0

commit r11-10402-g7bb5b326796af7d688c9976fba7ba3c2706481a0
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Nov 12 00:54:47 2022 +0100

    d: Fix ICE on named continue label in an unrolled loop [PR107592]

    Continue labels in an unrolled loop require a unique label per
    iteration.  Previously this used the Statement body node for each
    unrolled iteration to generate a new entry in the label hash table.
    This does not work when the continue label has an identifier, as said
    named label is pointing to the outer UnrolledLoopStatement node.

    What would happen is that during the lowering of `continue label', an
    automatic label associated with the unrolled loop would be generated,
    and a jump to that label inserted, but because it was never pushed by
    the visitor for the loop itself, it subsequently never gets emitted.

    To fix, correctly use the UnrolledLoopStatement as the key to look up
    and store the break/continue label pair, but remove the continue label
    from the value entry after every loop to force a new label to be
    generated by the next call to `push_continue_label'

            PR d/107592

    gcc/d/ChangeLog:

            * toir.cc (IRVisitor::push_unrolled_continue_label): New method.
            (IRVisitor::pop_unrolled_continue_label): New method.
            (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of
            push_continue_label and pop_continue_label.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr107592.d: New test.

    (cherry picked from commit 031d3f095520f0e1ee03e29b7ad5067c2a3f96e0)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/107592] ICE: gdc segfault on label continue
  2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
                   ` (3 preceding siblings ...)
  2022-11-30 21:03 ` cvs-commit at gcc dot gnu.org
@ 2022-11-30 21:05 ` cvs-commit at gcc dot gnu.org
  2022-11-30 21:10 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-30 21:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:f3cfcde3d69e2e8d305c4d4d662a26cd25e8398c

commit r10-11103-gf3cfcde3d69e2e8d305c4d4d662a26cd25e8398c
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Nov 12 00:54:47 2022 +0100

    d: Fix ICE on named continue label in an unrolled loop [PR107592]

    Continue labels in an unrolled loop require a unique label per
    iteration.  Previously this used the Statement body node for each
    unrolled iteration to generate a new entry in the label hash table.
    This does not work when the continue label has an identifier, as said
    named label is pointing to the outer UnrolledLoopStatement node.

    What would happen is that during the lowering of `continue label', an
    automatic label associated with the unrolled loop would be generated,
    and a jump to that label inserted, but because it was never pushed by
    the visitor for the loop itself, it subsequently never gets emitted.

    To fix, correctly use the UnrolledLoopStatement as the key to look up
    and store the break/continue label pair, but remove the continue label
    from the value entry after every loop to force a new label to be
    generated by the next call to `push_continue_label'

            PR d/107592

    gcc/d/ChangeLog:

            * toir.cc (IRVisitor::push_unrolled_continue_label): New method.
            (IRVisitor::pop_unrolled_continue_label): New method.
            (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of
            push_continue_label and pop_continue_label.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr107592.d: New test.

    (cherry picked from commit 031d3f095520f0e1ee03e29b7ad5067c2a3f96e0)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug d/107592] ICE: gdc segfault on label continue
  2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
                   ` (4 preceding siblings ...)
  2022-11-30 21:05 ` cvs-commit at gcc dot gnu.org
@ 2022-11-30 21:10 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-11-30 21:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #6 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Fix committed and backported to release branches.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-30 21:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 16:06 [Bug d/107592] New: ICE: gdc segfault on label continue zorael at gmail dot com
2022-11-09 17:32 ` [Bug d/107592] " ibuclaw at gdcproject dot org
2022-11-30 17:10 ` cvs-commit at gcc dot gnu.org
2022-11-30 21:01 ` cvs-commit at gcc dot gnu.org
2022-11-30 21:03 ` cvs-commit at gcc dot gnu.org
2022-11-30 21:05 ` cvs-commit at gcc dot gnu.org
2022-11-30 21:10 ` ibuclaw at gdcproject dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).