public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data
@ 2021-03-06  7:54 alexander.lelyakin at googlemail dot com
  2021-03-09 15:56 ` [Bug c++/99426] " alexander.lelyakin at googlemail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: alexander.lelyakin at googlemail dot com @ 2021-03-06  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99426
           Summary: [modules] failed to read compiled module cluster 1186:
                    Bad file data
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexander.lelyakin at googlemail dot com
  Target Milestone: ---

g++ -std=c++20 -fmodules-ts -x c++-system-header exception
g++ -std=c++20 -fmodules-ts -x c++-system-header stack
g++ -std=c++20 -fmodules-ts -x c++-system-header cuchar
g++ -std=c++20 -fmodules-ts -x c++-system-header cstdalign
g++ -std=c++20 -fmodules-ts -x c++-system-header ios
g++ -std=c++20 -fmodules-ts -x c++-system-header unordered_set
g++ -std=c++20 -fmodules-ts -x c++-system-header cerrno
g++ -std=c++20 -fmodules-ts -x c++-system-header cstdbool
g++ -std=c++20 -fmodules-ts -x c++-system-header cstddef
g++ -std=c++20 -fmodules-ts -x c++-system-header fstream
g++ -std=c++20 -fmodules-ts -x c++-system-header queue
g++ -std=c++20 -fmodules-ts -x c++-system-header latch
g++ -std=c++20 -fmodules-ts -x c++-system-header sstream
g++ -std=c++20 -fmodules-ts -x c++-system-header cwchar
g++ -std=c++20 -fmodules-ts -x c++-system-header semaphore
g++ -std=c++20 -fmodules-ts -x c++-system-header type_traits
g++ -std=c++20 -fmodules-ts -x c++-system-header cstdint
g++ -std=c++20 -fmodules-ts -x c++-system-header locale
g++ -std=c++20 -fmodules-ts -x c++-system-header iomanip
----
In module imported at /usr/local/include/c++/11.0.1/iomanip:43:1:
/usr/local/include/c++/11.0.1/locale: error: failed to read compiled module
cluster 1186: Bad file data
/usr/local/include/c++/11.0.1/locale: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.1/locale.gcm’
In file included from /usr/local/include/c++/11.0.1/string:55,
                 from /usr/local/include/c++/11.0.1/bits/locale_classes.h:40,
                 from /usr/local/include/c++/11.0.1/bits/ios_base.h:41,
                 from /usr/local/include/c++/11.0.1/iomanip:40:
/usr/local/include/c++/11.0.1/bits/basic_string.h:6608:54: fatal error: failed
to load pendings for ‘__gnu_cxx::__stoa’
 6608 |                                         __idx, __base); }
      |                                                      ^
compilation terminated.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
@ 2021-03-09 15:56 ` alexander.lelyakin at googlemail dot com
  2021-03-12  5:40 ` alexander.lelyakin at googlemail dot com
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: alexander.lelyakin at googlemail dot com @ 2021-03-09 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Alexander Lelyakin <alexander.lelyakin at googlemail dot com> ---
in version 20210308 diagnostic changed:
In file included from /usr/local/include/c++/11.0.1/iomanip:45:
/usr/local/include/c++/11.0.1/bits/quoted_string.h: In destructor ‘constexpr
std::allocator< <template-parameter-1-1> >::~allocator() [with _Tp =
char32_t]’:
/usr/local/include/c++/11.0.1/bits/quoted_string.h:69:29: internal compiler
error: tree check: expected template_decl, have function_decl in decl_value, at
cp/module.cc:7938
   69 |       struct _Quoted_string<basic_string_view<_CharT, _Traits>, _CharT>
      |                             ^~~~~~~~~~~~~~~~~
0x875ba8 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:9814
0x6e61c9 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3353
0x6e61c9 trees_in::decl_value()
        ../../gcc/gcc/cp/module.cc:7938
0xa66d17 trees_in::tree_node(bool)
        ../../gcc/gcc/cp/module.cc:9174
0xa6d36b module_state::read_cluster(unsigned int)
        ../../gcc/gcc/cp/module.cc:14858
0xa6d86d module_state::load_section(unsigned int, binding_slot*)
        ../../gcc/gcc/cp/module.cc:18125
0xa6d92f module_state::lazy_load(unsigned int, binding_slot*)
        ../../gcc/gcc/cp/module.cc:18779
0xa70b67 lazy_load_pendings(tree_node*)
        ../../gcc/gcc/cp/module.cc:18872
0xa79448 maybe_lazily_declare
        ../../gcc/gcc/cp/name-lookup.c:1922
0xa79448 get_class_binding(tree_node*, tree_node*, bool)
        ../../gcc/gcc/cp/name-lookup.c:1958
0xb3c3be lookup_field_r
        ../../gcc/gcc/cp/search.c:1023
0xb3c646 dfs_walk_all(tree_node*, tree_node* (*)(tree_node*, void*), tree_node*
(*)(tree_node*, void*), void*)
        ../../gcc/gcc/cp/search.c:1453
0xb3c646 lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
        ../../gcc/gcc/cp/search.c:1166
0xa759c5 get_class_binding
        ../../gcc/gcc/cp/name-lookup.c:5327
0xa7cebf outer_binding(tree_node*, cxx_binding*, bool)
        ../../gcc/gcc/cp/name-lookup.c:7641
0xa8182a check_local_shadow
        ../../gcc/gcc/cp/name-lookup.c:3143
0xa85d8b do_pushdecl
        ../../gcc/gcc/cp/name-lookup.c:3767
0xa872d2 do_pushdecl
        ../../gcc/gcc/cp/name-lookup.c:3846
0xa872d2 pushdecl(tree_node*, bool)
        ../../gcc/gcc/cp/name-lookup.c:3846
0x9c61f1 do_push_parm_decls(tree_node*, tree_node*, tree_node**)
        ../../gcc/gcc/cp/decl.c:16847
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
  2021-03-09 15:56 ` [Bug c++/99426] " alexander.lelyakin at googlemail dot com
@ 2021-03-12  5:40 ` alexander.lelyakin at googlemail dot com
  2021-03-24 19:38 ` alexander.lelyakin at googlemail dot com
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: alexander.lelyakin at googlemail dot com @ 2021-03-12  5:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Alexander Lelyakin <alexander.lelyakin at googlemail dot com> ---
There is a shorter sequence:
g++ -std=c++20 -fmodules-ts -x c++-system-header typeindex
g++ -std=c++20 -fmodules-ts -x c++-system-header stop_token
g++ -std=c++20 -fmodules-ts -x c++-system-header optional
g++ -std=c++20 -fmodules-ts -x c++-system-header system_error
g++ -std=c++20 -fmodules-ts -x c++-system-header streambuf
g++ -std=c++20 -fmodules-ts -x c++-system-header exception
g++ -std=c++20 -fmodules-ts -x c++-system-header unordered_map
g++ -std=c++20 -fmodules-ts -x c++-system-header complex
----
In module imported at /usr/local/include/c++/11.0.1/ios:43:1,
        included from /usr/local/include/c++/11.0.1/istream:38,
                 from /usr/local/include/c++/11.0.1/sstream:38,
                 from /usr/local/include/c++/11.0.1/complex:45:
/usr/local/include/c++/11.0.1/streambuf: error: failed to read compiled module
cluster 1269: Bad file data
/usr/local/include/c++/11.0.1/streambuf: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.1/streambuf.gcm’
In file included from /usr/local/include/c++/11.0.1/string:55,
                 from /usr/local/include/c++/11.0.1/bits/locale_classes.h:40,
                 from /usr/local/include/c++/11.0.1/bits/ios_base.h:41,
                 from /usr/local/include/c++/11.0.1/ios:42,
                 from /usr/local/include/c++/11.0.1/istream:38,
                 from /usr/local/include/c++/11.0.1/sstream:38,
                 from /usr/local/include/c++/11.0.1/complex:45:
/usr/local/include/c++/11.0.1/bits/basic_string.h:6608:54: fatal error: failed
to load pendings for ‘__gnu_cxx::__stoa’
 6608 |                                         __idx, __base); }
      |                                                      ^
compilation terminated.
----
g++ (GCC) 11.0.1 20210311 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
  2021-03-09 15:56 ` [Bug c++/99426] " alexander.lelyakin at googlemail dot com
  2021-03-12  5:40 ` alexander.lelyakin at googlemail dot com
@ 2021-03-24 19:38 ` alexander.lelyakin at googlemail dot com
  2021-03-30  1:34 ` mpolacek at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: alexander.lelyakin at googlemail dot com @ 2021-03-24 19:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Alexander Lelyakin <alexander.lelyakin at googlemail dot com> ---
There is a shorter sequence:
----
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header system_error
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header streambuf
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header complex
----
In module imported at /usr/local/include/c++/11.0.1/ios:43:1,
        included from /usr/local/include/c++/11.0.1/istream:38,
                 from /usr/local/include/c++/11.0.1/sstream:38,
                 from /usr/local/include/c++/11.0.1/complex:45:
/usr/local/include/c++/11.0.1/streambuf: error: failed to read compiled module
cluster 1269: Bad file data
/usr/local/include/c++/11.0.1/streambuf: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.1/streambuf.gcm’
In file included from /usr/local/include/c++/11.0.1/string:55,
                 from /usr/local/include/c++/11.0.1/bits/locale_classes.h:40,
                 from /usr/local/include/c++/11.0.1/bits/ios_base.h:41,
                 from /usr/local/include/c++/11.0.1/ios:42,
                 from /usr/local/include/c++/11.0.1/istream:38,
                 from /usr/local/include/c++/11.0.1/sstream:38,
                 from /usr/local/include/c++/11.0.1/complex:45:
/usr/local/include/c++/11.0.1/bits/basic_string.h:6608:54: fatal error: failed
to load pendings for ‘__gnu_cxx::__stoa’
 6608 |                                         __idx, __base); }
      |                                                      ^
compilation terminated.
----
g++ (GCC) 11.0.1 20210324 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (2 preceding siblings ...)
  2021-03-24 19:38 ` alexander.lelyakin at googlemail dot com
@ 2021-03-30  1:34 ` mpolacek at gcc dot gnu.org
  2021-03-30  6:50 ` alexander.lelyakin at googlemail dot com
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-30  1:34 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-03-30
                 CC|                            |mpolacek at gcc dot gnu.org

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (3 preceding siblings ...)
  2021-03-30  1:34 ` mpolacek at gcc dot gnu.org
@ 2021-03-30  6:50 ` alexander.lelyakin at googlemail dot com
  2022-09-08  4:39 ` markmigm at gmail dot com
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: alexander.lelyakin at googlemail dot com @ 2021-03-30  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Alexander Lelyakin <alexander.lelyakin at googlemail dot com> ---
More sequences:

/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header system_error
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header streambuf
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header iomanip
----
In module imported at /usr/local/include/c++/11.0.1/bits/locale_facets.h:44:1,
        included from /usr/local/include/c++/11.0.1/locale:40,
                 from /usr/local/include/c++/11.0.1/iomanip:43:
/usr/local/include/c++/11.0.1/streambuf: error: failed to read compiled module
cluster 1269: Bad file data
/usr/local/include/c++/11.0.1/streambuf: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.1/streambuf.gcm’
In file included from /usr/local/include/c++/11.0.1/string:55,
                 from /usr/local/include/c++/11.0.1/bits/locale_classes.h:40,
                 from /usr/local/include/c++/11.0.1/bits/ios_base.h:41,
                 from /usr/local/include/c++/11.0.1/iomanip:40:
/usr/local/include/c++/11.0.1/bits/basic_string.h:6607:40: fatal error: failed
to load pendings for ‘__gnu_cxx::__stoa’
 6607 |   { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi",
__str.c_str(),
      |           
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 6608 |                                         __idx, __base); }
      |                                         ~~~~~~~~~~~~~~
compilation terminated.
----
g++ (GCC) 11.0.1 20210329 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header system_error
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header streambuf
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header iomanip
----
In module imported at /usr/local/include/c++/11.0.1/bits/locale_facets.h:44:1,
        included from /usr/local/include/c++/11.0.1/locale:40,
                 from /usr/local/include/c++/11.0.1/iomanip:43:
/usr/local/include/c++/11.0.1/streambuf: error: failed to read compiled module
cluster 1269: Bad file data
/usr/local/include/c++/11.0.1/streambuf: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.1/streambuf.gcm’
In file included from /usr/local/include/c++/11.0.1/string:55,
                 from /usr/local/include/c++/11.0.1/bits/locale_classes.h:40,
                 from /usr/local/include/c++/11.0.1/bits/ios_base.h:41,
                 from /usr/local/include/c++/11.0.1/iomanip:40:
/usr/local/include/c++/11.0.1/bits/basic_string.h:6607:40: fatal error: failed
to load pendings for ‘__gnu_cxx::__stoa’
 6607 |   { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi",
__str.c_str(),
      |           
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 6608 |                                         __idx, __base); }
      |                                         ~~~~~~~~~~~~~~
compilation terminated.


/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header streambuf
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header ios
/usr/local/bin/g++ -std=c++20 -fmodules-ts -x c++-system-header
condition_variable
----
In module imported at /usr/local/include/c++/11.0.1/ostream:38:1,
        included from /usr/local/include/c++/11.0.1/bits/unique_ptr.h:42,
                 from /usr/local/include/c++/11.0.1/bits/shared_ptr_base.h:59,
                 from /usr/local/include/c++/11.0.1/bits/shared_ptr.h:53,
                 from /usr/local/include/c++/11.0.1/condition_variable:43:
/usr/local/include/c++/11.0.1/ios: error: failed to read compiled module
cluster 1295: Bad file data
/usr/local/include/c++/11.0.1/ios: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.1/ios.gcm’
In file included from /usr/local/include/c++/11.0.1/string:55,
                 from /usr/local/include/c++/11.0.1/stdexcept:39,
                 from /usr/local/include/c++/11.0.1/system_error:41,
                 from /usr/local/include/c++/11.0.1/bits/std_mutex.h:39,
                 from /usr/local/include/c++/11.0.1/condition_variable:40:
/usr/local/include/c++/11.0.1/bits/basic_string.h:6607:40: fatal error: failed
to load pendings for ‘__gnu_cxx::__stoa’
 6607 |   { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi",
__str.c_str(),
      |           
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 6608 |                                         __idx, __base); }
      |                                         ~~~~~~~~~~~~~~
compilation terminated.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (4 preceding siblings ...)
  2021-03-30  6:50 ` alexander.lelyakin at googlemail dot com
@ 2022-09-08  4:39 ` markmigm at gmail dot com
  2024-02-27  2:15 ` ppalka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: markmigm at gmail dot com @ 2022-09-08  4:39 UTC (permalink / raw)
  To: gcc-bugs

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

Mark Millard <markmigm at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |markmigm at gmail dot com

--- Comment #5 from Mark Millard <markmigm at gmail dot com> ---
I've run into this sort of problem under Fedora 36 with its g++ 12.2.1 :

# rm -fr gcm.cache/*
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC ios
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC iostream
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC ostream
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC iomanip
In module imported at /usr/include/c++/12/istream:38:1,
        included from /usr/include/c++/12/sstream:38,
                 from /usr/include/c++/12/bits/quoted_string.h:38,
                 from /usr/include/c++/12/iomanip:45:
/usr/include/c++/12/ios: error: failed to read compiled module cluster 927: Bad
file data
/usr/include/c++/12/ios: note: compiled module file is
‘gcm.cache/./usr/include/c++/12/ios.gcm’
In file included from /usr/include/c++/12/string:53,
                 from /usr/include/c++/12/bits/locale_classes.h:40,
                 from /usr/include/c++/12/bits/ios_base.h:41,
                 from /usr/include/c++/12/iomanip:40:
/usr/include/c++/12/bits/basic_string.h:3972:40: fatal error: failed to load
pendings for ‘__gnu_cxx::__stoa’
 3972 |   { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi",
__str.c_str(),
      |           
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3973 |                                         __idx, __base); }
      |                                         ~~~~~~~~~~~~~~
compilation terminated.

But moving ios to be the last of the 4 did not generate any messages:

# rm -fr gcm.cache/*
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC iostream
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC ostream
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC iomanip
# c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -g -fPIC ios

I've run into other examples of order dependencies. I've not found a
way to predict a order that will be tolerated.

The "Last reconfirmed" could be updated.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (5 preceding siblings ...)
  2022-09-08  4:39 ` markmigm at gmail dot com
@ 2024-02-27  2:15 ` ppalka at gcc dot gnu.org
  2024-02-29 18:04 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-27  2:15 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
   Last reconfirmed|2021-03-30 00:00:00         |2024-2-21

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I've observed a similar error on trunk when compiling our xtreme-header
testcase without -fno-module-lazy:

$ g++ -fmodules-ts -std=c++20
gcc/testsuite/g++.dg/modules/xtreme-header_{a.H,b.C}
In module imported at gcc/testsuite/g++.dg/modules/xtreme-header_b.C:4:1:
./gcc/testsuite/g++.dg/modules/xtreme-header_a.H: At global scope:
./gcc/testsuite/g++.dg/modules/xtreme-header_a.H: error: failed to read
compiled module cluster 5541: Bad file data
./gcc/testsuite/g++.dg/modules/xtreme-header_a.H: note: compiled module file is
‘gcm.cache/,/gcc/testsuite/g++.dg/modules/xtreme-header_a.H.gcm’
In file included from
/scratchpad/gcc-build-prefix/include/c++/14.0.1/string:54,
                 from
/scratchpad/gcc-build-prefix/include/c++/14.0.1/bitset:52,
                 from gcc/testsuite/g++.dg/modules/xtreme-header.h:9:
/scratchpad/gcc-build-prefix/include/c++/14.0.1/bits/basic_string.h:4249:33:
fatal error: failed to load pendings for ‘std::__cxx11::basic_string’

Although this manifests as a serialization error, it's really a GC issue: a
streamed-in local class from entity_ary (which is not a GC root) gets
prematurely GC'd (since it's only reachable from entity_ary), and later when
resolving a reference to this GC'd local class the tt_entity case of
trees_in::tree_node fails.

In order to achieve a small reproducer, it seems setting
--param=ggc-min-heapsize/expand=0 is not enough, we need to add more collection
points:

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 2803824d11e..44c205b2529 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -27367,6 +27367,7 @@ instantiate_pending_templates (int retries)
        {
          tree instantiation = reopen_tinst_level ((*t)->tinst);
          bool complete = false;
+         ggc_collect (GGC_COLLECT_FORCE);

          if (TYPE_P (instantiation))
            {

With this patch to force GC after every instantiation, the following small
testcase can reproduce the issue:

$ cat xtreme-header.ii
struct string {
  template <typename T> void g(T) {
    struct _Local { };
  }
};

template <typename _Tp> void f(_Tp) { }

inline void foo() {
  string s;
  f(s);
  s.g(0);
}

$ cat xtreme-header_a.H
#include "xtreme-header.ii"

$ cat xtreme-header_b.C
#include "xtreme-header.ii"
import "xtreme-header_a.H";

$ g++ -fmodules-ts xtreme_header_{a.H,b.C}
./xtreme-header_a.H: error: failed to read compiled module cluster 4: Bad file
data
./xtreme-header_a.H: note: compiled module file is
‘gcm.cache/,/xtreme-header_a.H.gcm’
In file included from xtreme-header_b.C:1:
xtreme-header.ii:12:6: fatal error: failed to load pendings for ‘::string’

Another way to observe this GC issue by forcing a GC right before we clear
entity_ary and checking if any trees within entity_ary have been freed:

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 106af7bdb3e..a6edc9b033a 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -20460,6 +20460,12 @@ fini_modules (cpp_reader *reader, void *cookie, bool
has_inits)
   /* No need to lookup modules anymore.  */
   modules_hash = NULL;

+  ggc_collect (GGC_COLLECT_FORCE);
+  if (entity_ary)
+    for (binding_slot& t : *entity_ary)
+      if (!t.is_lazy () && (tree)t && TREE_CODE ((tree)t) == 0xa5a5)
+       printf ("XXX\n");
+
   /* Or entity array.  We still need the entity map to find import numbers. 
*/
   vec_free (entity_ary);
   entity_ary = NULL;

With that the following minimal testcase demonstrates the GC issue:

$ cat xtreme-header.ii
template <typename> void _M_construct() { struct A { }; }

$ g++ -fmodules-ts xtreme-header_{a.H,b.C}
XXX

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (6 preceding siblings ...)
  2024-02-27  2:15 ` ppalka at gcc dot gnu.org
@ 2024-02-29 18:04 ` ppalka at gcc dot gnu.org
  2024-04-03 21:19 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-29 18:04 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nathan at gcc dot gnu.org          |ppalka at gcc dot gnu.org
           Keywords|                            |rejects-valid
   Target Milestone|---                         |14.0

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (7 preceding siblings ...)
  2024-02-29 18:04 ` ppalka at gcc dot gnu.org
@ 2024-04-03 21:19 ` ppalka at gcc dot gnu.org
  2024-04-07 12:33 ` nickbegg at gmail dot com
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-03 21:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
There's a patch pending review at
https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647203.html

Until that's merged, one should be able to work around this error with a trunk
compiler by using --param=ggc-min-expand=1000 (or an ever larger value) to
prevent garbage collection from occurring as often.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (8 preceding siblings ...)
  2024-04-03 21:19 ` ppalka at gcc dot gnu.org
@ 2024-04-07 12:33 ` nickbegg at gmail dot com
  2024-04-07 14:56 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: nickbegg at gmail dot com @ 2024-04-07 12:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Nick Begg <nickbegg at gmail dot com> ---
I've been testing with the proposed patch, and I am still getting the same
errors.. 

/home/nick/inst/gcc-trunk-debug/bin/g++   -g -std=gnu++23 -Wall -Wextra
-freport-bug --param=ggc-min-expand=10000 -MD -MT
CMakeFiles/moduleMin.dir/main.cpp.o -MF CMakeFiles/moduleMin.dir/main.cpp.o.d
-fmodules-ts -fmodule-mapper=CMakeFiles/moduleMin.dir/main.cpp.o.modmap -MD
-fdeps-format=p1689r5 -x c++ -o CMakeFiles/moduleMin.dir/main.cpp.o -c
/home/nick/src/moduleMin/main.cpp
In module imported at /home/nick/src/moduleMin/main.cpp:3:1:
modA: error: failed to read compiled module cluster 3000: Bad file data
modA: note: compiled module file is ‘CMakeFiles/moduleMin.dir/modA.gcm’
modA: error: failed to read compiled module cluster 3001: Bad file data
In file included from /home/nick/src/moduleMin/main.cpp:1:
/home/nick/inst/gcc-trunk-debug/include/c++/14.0.1/format:1899:35: fatal error:
failed to load pendings for ‘std::__format::__formatter_int’
 1899 |         return _M_f._M_parse<char>(__pc);
      |                ~~~~~~~~~~~~~~~~~~~^~~~~~
compilation terminated.

I'm not sure if this is the same bug, or if I've uncovered a similar but
distinct bug... Various values of --param=ggc-min-expand don't seem to make a
difference.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (9 preceding siblings ...)
  2024-04-07 12:33 ` nickbegg at gmail dot com
@ 2024-04-07 14:56 ` ppalka at gcc dot gnu.org
  2024-04-07 20:49 ` nickbegg at gmail dot com
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-07 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Huh, interesting!  If --param=ggc-min-expand=10000 doesn't help then it's most
likely a distinct bug.  A testcase would be much appreciated if possible.

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (10 preceding siblings ...)
  2024-04-07 14:56 ` ppalka at gcc dot gnu.org
@ 2024-04-07 20:49 ` nickbegg at gmail dot com
  2024-04-12 19:52 ` ppalka at gcc dot gnu.org
  2024-04-12 19:53 ` ppalka at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: nickbegg at gmail dot com @ 2024-04-07 20:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Nick Begg <nickbegg at gmail dot com> ---
Testcase created in PR114630... Thanks

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (11 preceding siblings ...)
  2024-04-07 20:49 ` nickbegg at gmail dot com
@ 2024-04-12 19:52 ` ppalka at gcc dot gnu.org
  2024-04-12 19:53 ` ppalka at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 19:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:716af95fd454871473c4b118b8412b6a68459b75

commit r14-9948-716af95fd454871473c4b118b8412b6a68459b75
Author: Patrick Palka <ppalka@redhat.com>

    c++/modules: local type merging [PR99426]

    One known missing piece in the modules implementation is merging of a
    streamed-in local type (class or enum) with the corresponding in-TU
    version of the local type.  This missing piece turns out to cause a
    hard-to-reduce use-after-free GC issue due to the entity_ary not being
    marked as a GC root (deliberately), and manifests as a serialization
    error on stream-in as in PR99426 (see comment #6 for a reduction).  It's
    also reproducible on trunk when running the xtreme-header tests without
    -fno-module-lazy.

    This patch implements this missing piece, making us merge such local
    types according to their position within the containing function's
    definition, analogous to how we merge FIELD_DECLs of a class according
    to their index in the TYPE_FIELDS list.

            PR c++/99426

    gcc/cp/ChangeLog:

            * module.cc (merge_kind::MK_local_type): New enumerator.
            (merge_kind_name): Update.
            (trees_out::chained_decls): Move BLOCK-specific handling
            of DECL_LOCAL_DECL_P decls to ...
            (trees_out::core_vals) <case BLOCK>: ... here.  Stream
            BLOCK_VARS manually.
            (trees_in::core_vals) <case BLOCK>: Stream BLOCK_VARS
            manually.  Handle deduplicated local types..
            (trees_out::key_local_type): Define.
            (trees_in::key_local_type): Define.
            (trees_out::get_merge_kind) <case FUNCTION_DECL>: Return
            MK_local_type for a local type.
            (trees_out::key_mergeable) <case FUNCTION_DECL>: Use
            key_local_type.
            (trees_in::key_mergeable) <case FUNCTION_DECL>: Likewise.
            (trees_in::is_matching_decl): Be flexible with type mismatches
            for local entities.
            (trees_in::register_duplicate): Also register the
            DECL_TEMPLATE_RESULT of a TEMPLATE_DECL as a duplicate.
            (depset_cmp): Return 0 for equal IDENTIFIER_HASH_VALUEs.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/merge-17.h: New test.
            * g++.dg/modules/merge-17_a.H: New test.
            * g++.dg/modules/merge-17_b.C: New test.
            * g++.dg/modules/xtreme-header-7_a.H: New test.
            * g++.dg/modules/xtreme-header-7_b.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

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

* [Bug c++/99426] [modules] failed to read compiled module cluster 1186: Bad file data
  2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
                   ` (12 preceding siblings ...)
  2024-04-12 19:52 ` ppalka at gcc dot gnu.org
@ 2024-04-12 19:53 ` ppalka at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

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

--- Comment #12 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14 (although PR114630 remains at large).

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

end of thread, other threads:[~2024-04-12 19:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06  7:54 [Bug c++/99426] New: [modules] failed to read compiled module cluster 1186: Bad file data alexander.lelyakin at googlemail dot com
2021-03-09 15:56 ` [Bug c++/99426] " alexander.lelyakin at googlemail dot com
2021-03-12  5:40 ` alexander.lelyakin at googlemail dot com
2021-03-24 19:38 ` alexander.lelyakin at googlemail dot com
2021-03-30  1:34 ` mpolacek at gcc dot gnu.org
2021-03-30  6:50 ` alexander.lelyakin at googlemail dot com
2022-09-08  4:39 ` markmigm at gmail dot com
2024-02-27  2:15 ` ppalka at gcc dot gnu.org
2024-02-29 18:04 ` ppalka at gcc dot gnu.org
2024-04-03 21:19 ` ppalka at gcc dot gnu.org
2024-04-07 12:33 ` nickbegg at gmail dot com
2024-04-07 14:56 ` ppalka at gcc dot gnu.org
2024-04-07 20:49 ` nickbegg at gmail dot com
2024-04-12 19:52 ` ppalka at gcc dot gnu.org
2024-04-12 19:53 ` ppalka at gcc dot gnu.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).