public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/17891] New: SIGFPE results in infinite loop?
@ 2015-01-29 11:16 dje at google dot com
2021-08-11 11:35 ` [Bug gdb/17891] " cvs-commit at gcc dot gnu.org
2024-01-02 18:04 ` ssbssa at sourceware dot org
0 siblings, 2 replies; 3+ messages in thread
From: dje at google dot com @ 2015-01-29 11:16 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=17891
Bug ID: 17891
Summary: SIGFPE results in infinite loop?
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: dje at google dot com
I was testing current gdb on a program compiled with Two Level Linetables
http://wiki.dwarfstd.org/index.php?title=TwoLevelLineTables
and found gdb went into an infinite loop of SIGFPE->handle_sigfpe->SIGFPE
->handle_sigfpe->...
The bug for bad line table header version handling is bug 17890.
This bug is for the bad SIGFPE handling.
How is this supposed to work?
Repro:
Add a divide-by-zero to gdb after the event loop has been set up, put a
breakpoint on handle_sigfpe, run, continue, continue, continue, ...
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 715b090..a4bc9ff 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17140,6 +17140,9 @@ dwarf_decode_line_header (unsigned int offset, struct
dwarf2_cu *cu)
struct dwarf2_section_info *section;
bfd *abfd;
+ i = 0;
+ i = 3/i;
+
section = get_debug_line_section (cu);
dwarf2_read_section (dwarf2_per_objfile->objfile, section);
if (section->buffer == NULL)
Program received signal SIGFPE, Arithmetic exception.
0x00000000007c688c in dwarf_decode_line_header (offset=0, cu=0x12b5610)
at ../../binutils-gdb/gdb/dwarf2read.c:17144
17144 i = 3/i;
(top-gdb) c
Continuing.
Breakpoint 3, handle_sigfpe (sig=8) at ../../binutils-gdb/gdb/event-top.c:1006
1006 mark_async_signal_handler (sigfpe_token);
(top-gdb)
Continuing.
Program received signal SIGFPE, Arithmetic exception.
0x00000000007c688c in dwarf_decode_line_header (offset=0, cu=0x12b5610)
at ../../binutils-gdb/gdb/dwarf2read.c:17144
17144 i = 3/i;
(top-gdb)
Continuing.
Breakpoint 3, handle_sigfpe (sig=8) at ../../binutils-gdb/gdb/event-top.c:1006
1006 mark_async_signal_handler (sigfpe_token);
(top-gdb)
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/17891] SIGFPE results in infinite loop?
2015-01-29 11:16 [Bug gdb/17891] New: SIGFPE results in infinite loop? dje at google dot com
@ 2021-08-11 11:35 ` cvs-commit at gcc dot gnu.org
2024-01-02 18:04 ` ssbssa at sourceware dot org
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 11:35 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=17891
--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fb550a919a88bf4e3950dd7bcdf72f0a18d94206
commit fb550a919a88bf4e3950dd7bcdf72f0a18d94206
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Thu Jun 10 10:44:43 2021 +0100
gdb: terminate upon receipt of SIGFPE
GDB's SIGFPE handling is broken, this is PR gdb/16505 and
PR gdb/17891.
We currently try to use an async event token to process SIGFPE. So,
when a SIGFPE arrives the signal handler calls
mark_async_signal_handler then returns, effectively ignoring the
signal (for now).
The intention is that later the event loop will see that the async
token associated with SIGFPE has been marked and will call the async
handler, which just throws an error.
The problem is that SIGFPE is not safe to ignore. Ignoring a
SIGFPE (unless it is generated artificially, e.g. by raise()) is
undefined behaviour, after ignoring the signal on many targets we
return to the instruction that caused the SIGFPE to be raised, which
immediately causes another SIGFPE to be raised, we get stuck in an
infinite loop. The behaviour is certainly true on x86-64.
To view this behaviour I simply added some dummy code to GDB that
performed an integer divide by zero, compiled this on x86-64
GNU/Linux, ran GDB and saw GDB hang.
In this commit, I propose to remove all special handling of SIGFPE and
instead just let GDB make use of the default SIGFPE action, that is,
to terminate the process.
The only user visible change here should be:
- If a user sends a SIGFPE to GDB using something like kill,
previously GDB would just print an error and remain alive, now GDB
will terminate. This is inline with what happens if the user
sends GDB a SIGSEGV from kill though, so I don't see this as an
issue.
- If a bug in GDB causes a real SIGFPE, previously the users GDB
session would hang. Now the GDB session will terminate. Again,
this is inline with what happens if GDB receives a SIGSEGV due to
an internal bug.
In bug gdb/16505 there is mention that it would be nice if GDB did
more than just terminate when receiving a fatal signal. I haven't
done that in this commit, but later commits will move in that
direction.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16505
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17891
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/17891] SIGFPE results in infinite loop?
2015-01-29 11:16 [Bug gdb/17891] New: SIGFPE results in infinite loop? dje at google dot com
2021-08-11 11:35 ` [Bug gdb/17891] " cvs-commit at gcc dot gnu.org
@ 2024-01-02 18:04 ` ssbssa at sourceware dot org
1 sibling, 0 replies; 3+ messages in thread
From: ssbssa at sourceware dot org @ 2024-01-02 18:04 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=17891
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ssbssa at sourceware dot org
--- Comment #2 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to Sourceware Commits from comment #1)
> The master branch has been updated by Andrew Burgess
> <aburgess@sourceware.org>:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=fb550a919a88bf4e3950dd7bcdf72f0a18d94206
>
> commit fb550a919a88bf4e3950dd7bcdf72f0a18d94206
> Author: Andrew Burgess <andrew.burgess@embecosm.com>
> Date: Thu Jun 10 10:44:43 2021 +0100
>
> gdb: terminate upon receipt of SIGFPE
>
> GDB's SIGFPE handling is broken, this is PR gdb/16505 and
> PR gdb/17891.
Can this be closed now?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-02 18:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 11:16 [Bug gdb/17891] New: SIGFPE results in infinite loop? dje at google dot com
2021-08-11 11:35 ` [Bug gdb/17891] " cvs-commit at gcc dot gnu.org
2024-01-02 18:04 ` ssbssa at sourceware dot 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).