public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98741] New: [modules] ICE/SIGSEGV reading compiled module cluster
@ 2021-01-19  8:34 boris at kolpackov dot net
  2021-02-17 19:38 ` [Bug c++/98741] " nathan at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: boris at kolpackov dot net @ 2021-01-19  8:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98741
           Summary: [modules] ICE/SIGSEGV reading compiled module cluster
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris at kolpackov dot net
  Target Milestone: ---

Created attachment 49998
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49998&action=edit
Build transcript

The following simple module causes ICE/SIGSEGV:

// hello.mxx
export module hello;
import <string_view>;
export namespace hello
{
  void say_hello (const std::string_view& name);
}

// hello.cxx
module hello;
import <iostream>;
namespace hello
{
  void say_hello (const std::string_view& n)
  {
    std::cout << "Hello, " << n << '!' << std::endl;
  }
}

c++ ../../../tests/modules/gcc2/gcc-install/include/c++/11.0.0/h{string_view}
c++ ../../../tests/modules/gcc2/gcc-install/include/c++/11.0.0/h{iostream}
c++ mxx{hello}
c++ cxx{hello}
In module imported at
/home/boris/work/build2/cxx20-modules-examples/hello-module/hello/hello.mxx:2:1,
of module hello, imported at
/home/boris/work/build2/cxx20-modules-examples/hello-module/hello/hello.cxx:1:
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/string_view:
error: failed to read compiled module cluster 137: Bad file data
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/string_view:
note: compiled module file is
‘/home/boris/work/build2/cxx20-modules-examples/hello-module/build/cc/b
uild/modules/cxx/string_view-02af41185b22.gcm’
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/string_view:
error: failed to read compiled module cluster 448: Bad file data
/home/boris/work/build2/cxx20-modules-examples/hello-module/hello/hello.cxx:5:30:
internal compiler error: Segmentation fault
0x180310b crash_signal
        ../../gcc/gcc/toplev.c:327
0xa16316 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../gcc/gcc/tree.h:3451
0xc4a0b5 trees_in::key_mergeable(int, merge_kind, tree_node*, tree_node*,
tree_node*, tree_node*, bool)
        ../../gcc/gcc/cp/module.cc:10733
0xc3bd06 trees_in::decl_value()
        ../../gcc/gcc/cp/module.cc:8004
0xc41e8a trees_in::tree_node(bool)
        ../../gcc/gcc/cp/module.cc:9219
0xc5cc39 module_state::read_cluster(unsigned int)
        ../../gcc/gcc/cp/module.cc:14896
0xc66826 module_state::load_section(unsigned int, binding_slot*)
        ../../gcc/gcc/cp/module.cc:18036
0xc68a3c module_state::lazy_load(unsigned int, binding_slot*)
        ../../gcc/gcc/cp/module.cc:18685
0xc44657 trees_in::tree_node(bool)
        ../../gcc/gcc/cp/module.cc:9730
0xc47cd8 trees_in::decl_container()
        ../../gcc/gcc/cp/module.cc:10346
0xc3bc3a trees_in::decl_value()
        ../../gcc/gcc/cp/module.cc:7992
0xc41e8a trees_in::tree_node(bool)
        ../../gcc/gcc/cp/module.cc:9219
0xc5cc39 module_state::read_cluster(unsigned int)
        ../../gcc/gcc/cp/module.cc:14896
0xc66826 module_state::load_section(unsigned int, binding_slot*)
        ../../gcc/gcc/cp/module.cc:18036
0xc68a3c module_state::lazy_load(unsigned int, binding_slot*)
        ../../gcc/gcc/cp/module.cc:18685
0xc44657 trees_in::tree_node(bool)
        ../../gcc/gcc/cp/module.cc:9730
0xc42102 trees_in::tree_node(bool)
        ../../gcc/gcc/cp/module.cc:9269
0xc36133 trees_in::core_vals(tree_node*)
        ../../gcc/gcc/cp/module.cc:6624
0xc3810e trees_in::tree_node_vals(tree_node*)
        ../../gcc/gcc/cp/module.cc:7148
0xc3c012 trees_in::decl_value()
        ../../gcc/gcc/cp/module.cc:8043

The complete build transcript is attached.

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

* [Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster
  2021-01-19  8:34 [Bug c++/98741] New: [modules] ICE/SIGSEGV reading compiled module cluster boris at kolpackov dot net
@ 2021-02-17 19:38 ` nathan at gcc dot gnu.org
  2021-02-19 21:29 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-17 19:38 UTC (permalink / raw)
  To: gcc-bugs

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

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-02-17

--- Comment #1 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
// pr98741_a.H
namespace foo
{
}
// pr98741_b.H
namespace foo
{
}
// pr98741_b.C
export module Foo;
import "pr98741_a.H";
// pr98741_d.C
module Foo;
import "pr98741_b.H";

(added an assert earlier)

zathras:178>./cc1plus -fmodules-ts -quiet -fmodule-header pr98741_a.H
zathras:179>./cc1plus -fmodules-ts -quiet -fmodule-header pr98741_b.H
zathras:180>./cc1plus -fmodules-ts -quiet pr98741_c.C        
zathras:181>./cc1plus -fmodules-ts -quiet pr98741_d.C
pr98741_d.C:2:22: internal compiler error: in append_imported_binding_slot, at
cp/name-lookup.c:371
    2 | import "pr98741_b.H";
      |                      ^
0xd2fe45 append_imported_binding_slot
        ../../../src/gcc/cp/name-lookup.c:371
0xd5010c add_imported_namespace(tree_node*, tree_node*, unsigned int, unsigned
int, bool, bool)
        ../../../src/gcc/cp/name-lookup.c:9024

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

* [Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster
  2021-01-19  8:34 [Bug c++/98741] New: [modules] ICE/SIGSEGV reading compiled module cluster boris at kolpackov dot net
  2021-02-17 19:38 ` [Bug c++/98741] " nathan at gcc dot gnu.org
@ 2021-02-19 21:29 ` cvs-commit at gcc dot gnu.org
  2021-02-19 21:30 ` nathan at gcc dot gnu.org
  2021-03-04  7:48 ` boris at kolpackov dot net
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-19 21:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:14886cbe300c144a4390245d0515cdf28fc5f68f

commit r11-7307-g14886cbe300c144a4390245d0515cdf28fc5f68f
Author: Nathan Sidwell <nathan@acm.org>
Date:   Fri Feb 19 13:10:27 2021 -0800

    c++: Incorrect module-number ordering [PR 98741]

    One of the very strong invariants in modules is that module numbers
    are allocated such that (other than the current TU), all imports have
    lesser module numbers, and also that the binding vector is only
    appended to with increasing module numbers.   This broke down when
    module-directives became a thing and the preprocessing became entirely
    decoupled from parsing.  We'd load header units and their macros (but
    not symbols of course) during preprocessing.  Then we'd load named
    modules during parsing.  This could lead to the situation where a
    header unit appearing after a named import had a lower module number
    than the import.  Consequently, if they both bound the same
    identifier, the binding vector would be misorderd and bad things
    happen.

    This patch restores a pending import queue I previously had, but in
    simpler form (hurrah).  During preprocessing we queue all
    module-directives and when we meet one for a header unit we do the
    minimal loading for all of the queue, so they get appropriate
    numbering.  Then we load the preprocessor state for the header unit.

            PR c++/98741
            gcc/cp/
            * module.cc (pending_imports): New.
            (declare_module): Adjust test condition.
            (name_pending_imports): New.
            (preprocess_module): Reimplement using pending_imports.
            (preprocessed_module): Move name-getting to name_pending_imports.
            * name-lookup.c (append_imported_binding_slot): Assert module
            ordering is increasing.
            gcc/testsuite/
            * g++.dg/modules/pr98741_a.H: New.
            * g++.dg/modules/pr98741_b.H: New.
            * g++.dg/modules/pr98741_c.C: New.
            * g++.dg/modules/pr98741_d.C: New.

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

* [Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster
  2021-01-19  8:34 [Bug c++/98741] New: [modules] ICE/SIGSEGV reading compiled module cluster boris at kolpackov dot net
  2021-02-17 19:38 ` [Bug c++/98741] " nathan at gcc dot gnu.org
  2021-02-19 21:29 ` cvs-commit at gcc dot gnu.org
@ 2021-02-19 21:30 ` nathan at gcc dot gnu.org
  2021-03-04  7:48 ` boris at kolpackov dot net
  3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-19 21:30 UTC (permalink / raw)
  To: gcc-bugs

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

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

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

--- Comment #3 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
14886cbe300 2021-02-19 | c++: Incorrect module-number ordering [PR 98741]

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

* [Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster
  2021-01-19  8:34 [Bug c++/98741] New: [modules] ICE/SIGSEGV reading compiled module cluster boris at kolpackov dot net
                   ` (2 preceding siblings ...)
  2021-02-19 21:30 ` nathan at gcc dot gnu.org
@ 2021-03-04  7:48 ` boris at kolpackov dot net
  3 siblings, 0 replies; 5+ messages in thread
From: boris at kolpackov dot net @ 2021-03-04  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Boris Kolpackov <boris at kolpackov dot net> ---
Can confirm works for me, thanks!

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

end of thread, other threads:[~2021-03-04  7:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19  8:34 [Bug c++/98741] New: [modules] ICE/SIGSEGV reading compiled module cluster boris at kolpackov dot net
2021-02-17 19:38 ` [Bug c++/98741] " nathan at gcc dot gnu.org
2021-02-19 21:29 ` cvs-commit at gcc dot gnu.org
2021-02-19 21:30 ` nathan at gcc dot gnu.org
2021-03-04  7:48 ` boris at kolpackov dot net

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).