public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
@ 2020-12-17 10:32 pexu@gcc-bugzilla.mail.kapsi.fi
  2020-12-17 11:20 ` [Bug c++/98343] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: pexu@gcc-bugzilla.mail.kapsi.fi @ 2020-12-17 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98343
           Summary: [11 Regression] ICE in in relocate_ptrs, at
                    ggc-common.c:363 [PCH and C++20 std::source_location?]
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pexu@gcc-bugzilla.mail.kapsi.fi
  Target Milestone: ---
              Host: x86_64-w64-mingw32 x86_64-linux-gnu
            Target: aarch64-none-elf

Created attachment 49786
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49786&action=edit
An input header using std::source_location::current().

Hi.

Using GCC11 trunk built on 15.12.2020 @ x86_64-w64-mingw32 and 16.12.2020 @
x86_64-linux-gnu (sorry, unable to the latest trunk due to PR98300).

When attempting to precompile the following input header file GCC will ICE at
ggc-common.  However that happens only, and only if, certain warnings are
enabled.  `-Wall' will trigger this, and to be more precise any of the
following warnings: `-Wformat', `-Wnonnull' or `-Wrestrict'.

I do know if `std::source_location' is a red herring, or the warning flags, but
using a (large) real life file when the ICE occurs all symptoms point (dumping
a corresponding troublesome hash table) to  locations which use
`std::source_location::current()'.  Again, without `-Wall', PCH is compiled
just fine.  (The resulting GCH is over 128 MB.)

I'm able to reproduce this on both Windows and Linux.  I quickly tried a GCC10
(Windows) GCC9 (Linux) and they work just fine with that input file (though
those where not aarch64 targets;  I presume this really has nothing to with the
target).

$ cat pch.hpp
#if __has_include(<source_location>)
#include <source_location>
#else
#include <experimental/source_location>
namespace std { using namespace experimental; }
#endif
extern void location_fun(std::source_location loc =
std::source_location::current());


$ aarch64-none-elf-g++ -std=c++20 -c pch.hpp -Wall
pch.hpp:2:85: internal compiler error: in relocate_ptrs, at ggc-common.c:363
    2 | extern void location_fun(std::source_location loc =
std::source_location::current());

$ aarch64-none-elf-g++ -std=c++20 -c pch.hpp -Wall -wrapper gdb,--args
(gdb) break fancy_abort
(gdb) run
Thread 1 hit Breakpoint 1, fancy_abort (
    file=0x1eefb00 <(anonymous namespace)::pass_data_rtl_pre+576>
"<...>/src/gcc/gcc/ggc-common.c", line=363, function=0x1eefbc2 <(anonymous
namespace)::pass_data_rtl_pre+770> "relocate_ptrs")
    at <...>/src/gcc/gcc/diagnostic.c:1835

(gdb) bt
#0  fancy_abort (
    file=0x1eefb00 <(anonymous namespace)::pass_data_rtl_pre+576>
"<...>/src/gcc/gcc/ggc-common.c", line=363, function=0x1eefbc2 <(anonymous
namespace)::pass_data_rtl_pre+770> "relocate_ptrs")
    at <...>/src/gcc/gcc/diagnostic.c:1835
#1  0x0000000001c15cc8 in relocate_ptrs (ptr_p=0x210ea9b0, state_p=<optimized
out>)
    at <...>/src/gcc/gcc/ggc-common.c:351
#2  relocate_ptrs (ptr_p=0x210ea9b0, state_p=<optimized out>)
    at <...>/src/gcc/gcc/ggc-common.c:351
#3  0x0000000000471ea6 in ggc_remove<source_location_table_entry>::pch_nx
(cookie=0x1cf0fab0,
    op=0x8d75e0 <relocate_ptrs(void*, void*)>, p=...) at
<...>/src/gcc/gcc/hash-traits.h:255
#4  hashtab_entry_note_pointers<source_location_table_entry_hash>
(obj=<optimized out>, h=0x210d5960,
    op=0x8d75e0 <relocate_ptrs(void*, void*)>, cookie=0x1cf0fab0)
    at <...>/src/gcc/gcc/hash-table.h:1181
#5  0x00000000008d7d70 in gt_pch_save (f=<optimized out>) at
<...>/src/gcc/gcc/ggc-common.c:549
#6  0x00000000006b72d8 in c_common_write_pch () at
<...>/src/gcc/gcc/c-family/c-pch.c:177
#7  0x00000000004ce405 in c_parse_final_cleanups () at
<...>/src/gcc/gcc/cp/decl2.c:4911
#8  0x0000000000bc34a2 in compile_file () at <...>/src/gcc/gcc/toplev.c:457
#9  0x0000000001c8ff38 in do_compile () at <...>/src/gcc/gcc/toplev.c:2193
#10 toplev::main (this=this@entry=0x1cf0fe0e, argc=<optimized out>,
argc@entry=19, argv=<optimized out>,
    argv@entry=0x1f7425b0) at <...>/src/gcc/gcc/toplev.c:2332
#11 0x0000000001df7107 in main (argc=19, argv=0x1f7425b0) at
<...>/src/gcc/gcc/main.c:39

(gdb) print *((hash_table<source_location_table_entry_hash, false,
xcallocator>*)0x210d5960)
$1 = {m_entries = 0x210ea800, m_size = 127, m_n_elements = 1, m_n_deleted = 0,
m_searches = 1, m_collisions = 0,
  m_size_prime_index = 4, m_ggc = true, m_sanitize_eq_and_hash = true, static
m_gather_mem_stats = false}

(gdb) print *((hash_table<source_location_table_entry_hash, false,
xcallocator>*)0x210d5960)->m_entries@127
$2 = {{loc = 0, uid = 0, var = 0x0} <repeats 27 times>, {loc = 10262528, uid =
4294967295, var = 0x210eb2d0}, {
    loc = 0, uid = 0, var = 0x0} <repeats 99 times>}

(gdb) call expand_location (10262528)
$3 = {file = 0x1cf91790 "pch.hpp", line = 7, column = 83, data = 0x0, sysp =
false}


I noticed that on a few times `expand_location' displayed incorrect line or
column information for the given input location -- so, the real issue might be
buried quite deep.  (I was using an older GDB9, so it might an issue, too.)


I used this to probe the problematic warnings.  I took the list from
documentation, I presume it should be pretty complete.

$ for flag in -Waddress -Warray-bounds=1 -Wbool-compare -Wbool-operation
-Wc++11-compat -Wc++14-compat -Wcatch-value -Wchar-subscripts -Wcomment
-Wformat -Wformat-overflow -Wformat-truncation -Wint-in-bool-context
-Winit-self -Wlogical-not-parentheses -Wmaybe-uninitialized -Wmemset-elt-size
-Wmemset-transposed-args -Wmisleading-indentation -Wmissing-attributes
-Wmultistatement-macros -Wnarrowing  -Wnonnull -Wnonnull-compare -Wopenmp-simd
-Wparentheses -Wpessimizing-move -Wreorder -Wrestrict -Wreturn-type
-Wsequence-point -Wsign-compare -Wsizeof-pointer-div -Wsizeof-pointer-memaccess
-Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtautological-compare
-Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label
-Wunused-value -Wunused-variable -Wvolatile-register-var -Wzero-length-bounds;
do builtin echo $flag; aarch64-none-elf-g++ -std=c++20 -c pch.hpp $flag; done

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

* [Bug c++/98343] [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
  2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
@ 2020-12-17 11:20 ` jakub at gcc dot gnu.org
  2020-12-17 12:16 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-17 11:20 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
namespace std
{
  struct source_location
  {
    struct __impl
    {
      const char* _M_file_name;
      const char* _M_function_name;
      unsigned _M_line;
      unsigned _M_column;
    };
    const __impl* _M_impl = nullptr;
  };
}
const void *ptr = __builtin_source_location ();

is enough.

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

* [Bug c++/98343] [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
  2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
  2020-12-17 11:20 ` [Bug c++/98343] " jakub at gcc dot gnu.org
@ 2020-12-17 12:16 ` jakub at gcc dot gnu.org
  2020-12-17 13:50 ` pexu@gcc-bugzilla.mail.kapsi.fi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-17 12:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-12-17
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49788
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49788&action=edit
gcc11-pr98343.patch

Untested fix.

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

* [Bug c++/98343] [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
  2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
  2020-12-17 11:20 ` [Bug c++/98343] " jakub at gcc dot gnu.org
  2020-12-17 12:16 ` jakub at gcc dot gnu.org
@ 2020-12-17 13:50 ` pexu@gcc-bugzilla.mail.kapsi.fi
  2020-12-18  7:03 ` pexu@gcc-bugzilla.mail.kapsi.fi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pexu@gcc-bugzilla.mail.kapsi.fi @ 2020-12-17 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Pekka S <pexu@gcc-bugzilla.mail.kapsi.fi> ---
Hi.

Thanks.

Applied the patch to the latest trunk, built on x86_64-linux-gnu and tested
that it indeed fixes both of these test cases.  Did not try on
x86_64-w64-mingw32 yet.  I presume it will work just fine.

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

* [Bug c++/98343] [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
  2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
                   ` (2 preceding siblings ...)
  2020-12-17 13:50 ` pexu@gcc-bugzilla.mail.kapsi.fi
@ 2020-12-18  7:03 ` pexu@gcc-bugzilla.mail.kapsi.fi
  2020-12-18  9:08 ` cvs-commit at gcc dot gnu.org
  2020-12-18  9:09 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pexu@gcc-bugzilla.mail.kapsi.fi @ 2020-12-18  7:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Pekka S <pexu@gcc-bugzilla.mail.kapsi.fi> ---
And indeed the patch works on x86_64-w64-mingw32, too.

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

* [Bug c++/98343] [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
  2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
                   ` (3 preceding siblings ...)
  2020-12-18  7:03 ` pexu@gcc-bugzilla.mail.kapsi.fi
@ 2020-12-18  9:08 ` cvs-commit at gcc dot gnu.org
  2020-12-18  9:09 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-18  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:11f07ef37786d10517121fc6226681cd1aa2aea2

commit r11-6252-g11f07ef37786d10517121fc6226681cd1aa2aea2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Dec 18 10:07:28 2020 +0100

    c++: Fix PCH ICE with __builtin_source_location [PR98343]

    Seems the ggc_remove ppc_nx 3 operand member relies on the hash tables to
    contain pointers in the first element, which is not the case for
    source_location_table* hash table, which has location_t and unsigned as
    first two members and pointer somewhere else.
    I've tried to change:
       static void
       pch_nx (T &p, gt_pointer_operator op, void *cookie)
       {
    -    op (&p, cookie);
    +    extern void gt_pch_nx (T *, gt_pointer_operator, void *);
    +    gt_pch_nx (&p, op, cookie);
       }
    in hash-traits.h, but that failed miserably.
    So, this patch instead overrides the two pch_nx overloads (only the second
    one is needed, the former one is identical to the ggc_remove one) but I
need
    to override both.

    2020-12-18  Jakub Jelinek  <jakub@redhat.com>

            PR c++/98343
            * cp-gimplify.c (source_location_table_entry_hash::pch_nx):
Override
            static member functions from ggc_remove.

            * g++.dg/pch/pr98343.C: New test.
            * g++.dg/pch/pr98343.Hs: New file.

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

* [Bug c++/98343] [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?]
  2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
                   ` (4 preceding siblings ...)
  2020-12-18  9:08 ` cvs-commit at gcc dot gnu.org
@ 2020-12-18  9:09 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-18  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |11.0

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-12-18  9:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 10:32 [Bug c++/98343] New: [11 Regression] ICE in in relocate_ptrs, at ggc-common.c:363 [PCH and C++20 std::source_location?] pexu@gcc-bugzilla.mail.kapsi.fi
2020-12-17 11:20 ` [Bug c++/98343] " jakub at gcc dot gnu.org
2020-12-17 12:16 ` jakub at gcc dot gnu.org
2020-12-17 13:50 ` pexu@gcc-bugzilla.mail.kapsi.fi
2020-12-18  7:03 ` pexu@gcc-bugzilla.mail.kapsi.fi
2020-12-18  9:08 ` cvs-commit at gcc dot gnu.org
2020-12-18  9:09 ` jakub 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).