public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100877] New: g++ freezes system by consuming infinite amount of memory
@ 2021-06-02 15:19 wang_feng at live dot com
2021-06-03 3:36 ` [Bug c++/100877] " StevenSun2021 at hotmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: wang_feng at live dot com @ 2021-06-02 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100877
Bug ID: 100877
Summary: g++ freezes system by consuming infinite amount of
memory
Product: gcc
Version: 11.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: wang_feng at live dot com
Target Milestone: ---
Created attachment 50910
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50910&action=edit
The preprocessed source code to reproduce the problem.
g++ tends to allocate infinite amount of memory while compiling this program.
1. g++ version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--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-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)
2. compile command (dcgan.cc is attached with this report):
g++ -c -std=c++20 -Wall -Wextra -fmax-errors=1 -ftemplate-backtrace-limit=0
-fdata-sections -ffunction-sections -funsafe-math-optimizations
-fconcepts-diagnostics-depth=4 -ftemplate-depth=100860 -Ofast -flto -pipe
-march=native ./dcgan.cc
3. host system:
Arch Linux 5.10.39-1-lts #1 SMP Sat, 22 May 2021 10:57:31 +0000 x86_64
GNU/Linux
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/100877] g++ freezes system by consuming infinite amount of memory
2021-06-02 15:19 [Bug c++/100877] New: g++ freezes system by consuming infinite amount of memory wang_feng at live dot com
@ 2021-06-03 3:36 ` StevenSun2021 at hotmail dot com
2021-06-03 3:58 ` StevenSun2021 at hotmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: StevenSun2021 at hotmail dot com @ 2021-06-03 3:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100877
--- Comment #1 from Steven Sun <StevenSun2021 at hotmail dot com> ---
I look at the call stack. Most of the time is wasted on `dump_template_parms`
in `gcc/cp/error.c`. I commented several functions calling it:
(I'm using stage-1 compiler)
`announce_function` in `gcc/toplev.c`
`push_tinst_level_loc` in `gcc/cp/pt.c`
`cp_printer` in `gcc/cp/error.c` (directly return true)
Then I got the output after a few seconds.
----------------------
examples/../include/./model.hpp: In instantiation of ‘’:
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:61:77: required from ‘’
examples/../include/./model.hpp:55:147: [ skipping 8 instantiation contexts,
use -ftemplate-backtrace-limit=0 to disable ]
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:55:147: recursively required from ‘’
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:60:77: required from ‘’
examples/../include/./model.hpp:60:77: recursively required from ‘’
examples/../include/./model.hpp:55:147: recursively required from ‘’
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:55:147: recursively required from ‘’
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:60:77: required from ‘’
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:382:55: required from ‘’
examples/dcgan.cc:48:43: required from here
examples/../include/./model.hpp:59:96: error: ‘’ has no member named ‘’
----------------------
But I cannot give the output. Because the dumping process will lead to an out
of memory.
If I disable member access check, it gives an error
---------------------
examples/../include/./model.hpp: In instantiation of ‘’:
examples/../include/./model.hpp:55:147: recursively required from ‘’
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:60:77: required from ‘’
examples/../include/./model.hpp:55:147: required from ‘’
examples/../include/./model.hpp:382:55: required from ‘’
examples/dcgan.cc:48:43: required from here
examples/../include/./model.hpp:60:77: error: use of ‘’ before deduction of
‘auto’
--------------------
It's the same source location!
and it is in your definition of
--------------------
template< Expression Ex, Place_Holder Ph, Expression Ey >
auto replace_placeholder_with_expression( Ex const& ex, Ph const&
old_place_holder, Ey const& new_expression )
--------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/100877] g++ freezes system by consuming infinite amount of memory
2021-06-02 15:19 [Bug c++/100877] New: g++ freezes system by consuming infinite amount of memory wang_feng at live dot com
2021-06-03 3:36 ` [Bug c++/100877] " StevenSun2021 at hotmail dot com
@ 2021-06-03 3:58 ` StevenSun2021 at hotmail dot com
2021-06-03 9:48 ` wang_feng at live dot com
2021-06-03 12:02 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: StevenSun2021 at hotmail dot com @ 2021-06-03 3:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100877
Steven Sun <StevenSun2021 at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |StevenSun2021 at hotmail dot com
--- Comment #2 from Steven Sun <StevenSun2021 at hotmail dot com> ---
Feng use a non-exist member in your definition of
--------------------
template< Expression Ex, Place_Holder Ph, Expression Ey >
auto replace_placeholder_with_expression( Ex const& ex, Ph const&
old_place_holder, Ey const& new_expression )
--------------------
namely `ex.reset_action_`. It the one and only bug in your code. It compiles in
a few seconds after being fixed.
CONCLUSION: No bug in GCC but a stupid bug in Feng's code.
But interestingly, GCC eats so much memory to dump an error message involving
lambdas, template lambdas, and templates (eats 20G in my desktop, >400G in
Feng's cluster).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/100877] g++ freezes system by consuming infinite amount of memory
2021-06-02 15:19 [Bug c++/100877] New: g++ freezes system by consuming infinite amount of memory wang_feng at live dot com
2021-06-03 3:36 ` [Bug c++/100877] " StevenSun2021 at hotmail dot com
2021-06-03 3:58 ` StevenSun2021 at hotmail dot com
@ 2021-06-03 9:48 ` wang_feng at live dot com
2021-06-03 12:02 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: wang_feng at live dot com @ 2021-06-03 9:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100877
Feng Wang <wang_feng at live dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Feng Wang <wang_feng at live dot com> ---
A bug in the attached code causes this problem.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/100877] g++ freezes system by consuming infinite amount of memory
2021-06-02 15:19 [Bug c++/100877] New: g++ freezes system by consuming infinite amount of memory wang_feng at live dot com
` (2 preceding siblings ...)
2021-06-03 9:48 ` wang_feng at live dot com
@ 2021-06-03 12:02 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-03 12:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100877
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |INVALID
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-06-03 12:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 15:19 [Bug c++/100877] New: g++ freezes system by consuming infinite amount of memory wang_feng at live dot com
2021-06-03 3:36 ` [Bug c++/100877] " StevenSun2021 at hotmail dot com
2021-06-03 3:58 ` StevenSun2021 at hotmail dot com
2021-06-03 9:48 ` wang_feng at live dot com
2021-06-03 12:02 ` redi 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).