[Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster

2021-03-03 Thread boris at kolpackov dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98741

--- Comment #4 from Boris Kolpackov  ---
Can confirm works for me, thanks!

[Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster

2021-02-19 Thread nathan at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98741

Nathan Sidwell  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #3 from Nathan Sidwell  ---
14886cbe300 2021-02-19 | c++: Incorrect module-number ordering [PR 98741]

[Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster

2021-02-19 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98741

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Nathan Sidwell :

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

commit r11-7307-g14886cbe300c144a4390245d0515cdf28fc5f68f
Author: Nathan Sidwell 
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.

[Bug c++/98741] [modules] ICE/SIGSEGV reading compiled module cluster

2021-02-17 Thread nathan at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98741

Nathan Sidwell  changed:

   What|Removed |Added

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

--- Comment #1 from Nathan Sidwell  ---
// 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