public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC.
@ 2021-11-09 10:19 xiaxm at smail dot nju.edu.cn
2021-11-09 10:23 ` [Bug c++/103153] " marxin at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: xiaxm at smail dot nju.edu.cn @ 2021-11-09 10:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103153
Bug ID: 103153
Summary: The recursive call in C++ leads to crashes of GCC.
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: xiaxm at smail dot nju.edu.cn
Target Milestone: ---
The following code can be well compiled, however when execute it, GCC crashes
with segmentation fault.
========================
#include <iostream>
#include <exception>
int main(){
try{
throw -1;
}
catch(int e){
main();
}
return 0;
}
========================
Segmentation fault (core dumped)
gcc version 9.3.0 on Ubuntu 20.04
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103153] The recursive call in C++ leads to crashes of GCC.
2021-11-09 10:19 [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC xiaxm at smail dot nju.edu.cn
@ 2021-11-09 10:23 ` marxin at gcc dot gnu.org
2021-11-09 10:24 ` marxin at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-09 10:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103153
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2021-11-09
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Well, the code causes a stack overflow, it's invalid if I see correctly.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103153] The recursive call in C++ leads to crashes of GCC.
2021-11-09 10:19 [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC xiaxm at smail dot nju.edu.cn
2021-11-09 10:23 ` [Bug c++/103153] " marxin at gcc dot gnu.org
@ 2021-11-09 10:24 ` marxin at gcc dot gnu.org
2021-11-09 10:27 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-09 10:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103153
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
g++ pr103153.C && valgrind ./a.out
==1687== Memcheck, a memory error detector
==1687== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1687== Using Valgrind-3.17.0.GIT and LibVEX; rerun with -h for copyright info
==1687== Command: ./a.out
==1687==
==1687== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1687==
==1687== Process terminating with default action of signal 11 (SIGSEGV):
dumping core
==1687== Access not within mapped region at address 0x1FFE801FE8
==1687== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1687== at 0x4B9D520: get_cie_encoding (unwind-dw2-fde.c:300)
==1687== If you believe this happened as a result of a stack
==1687== overflow in your program's main thread (unlikely but
==1687== possible), you can try to increase the size of the
==1687== main thread stack using the --main-stacksize= flag.
==1687== The main thread stack size used in this run was 8388608.
==1687== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103153] The recursive call in C++ leads to crashes of GCC.
2021-11-09 10:19 [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC xiaxm at smail dot nju.edu.cn
2021-11-09 10:23 ` [Bug c++/103153] " marxin at gcc dot gnu.org
2021-11-09 10:24 ` marxin at gcc dot gnu.org
@ 2021-11-09 10:27 ` pinskia at gcc dot gnu.org
2021-11-09 10:30 ` jakub at gcc dot gnu.org
2021-11-09 10:39 ` redi at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-09 10:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103153
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|WAITING |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
"however when execute it"
Yes because the code has an infinite stack usage.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103153] The recursive call in C++ leads to crashes of GCC.
2021-11-09 10:19 [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC xiaxm at smail dot nju.edu.cn
` (2 preceding siblings ...)
2021-11-09 10:27 ` pinskia at gcc dot gnu.org
@ 2021-11-09 10:30 ` jakub at gcc dot gnu.org
2021-11-09 10:39 ` redi at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-09 10:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103153
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The code is invalid both because of the endless recursion into which it runs
and because in C++ main can't be called. See
https://eel.is/c++draft/basic.start.main#3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103153] The recursive call in C++ leads to crashes of GCC.
2021-11-09 10:19 [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC xiaxm at smail dot nju.edu.cn
` (3 preceding siblings ...)
2021-11-09 10:30 ` jakub at gcc dot gnu.org
@ 2021-11-09 10:39 ` redi at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-09 10:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103153
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Xinmeng Xia from comment #0)
> The following code can be well compiled, however when execute it, GCC
> crashes with segmentation fault.
No, your program crashes, GCC doesn't.
Any use of main is undefined in C++, especially calling it. This program is
just broken and of course it crashes.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-09 10:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09 10:19 [Bug c++/103153] New: The recursive call in C++ leads to crashes of GCC xiaxm at smail dot nju.edu.cn
2021-11-09 10:23 ` [Bug c++/103153] " marxin at gcc dot gnu.org
2021-11-09 10:24 ` marxin at gcc dot gnu.org
2021-11-09 10:27 ` pinskia at gcc dot gnu.org
2021-11-09 10:30 ` jakub at gcc dot gnu.org
2021-11-09 10:39 ` 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).