public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust
@ 2015-07-14 23:58 jreiser at bitwagon dot com
  2015-07-15  3:04 ` [Bug libgcc/66874] " hjl.tools at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jreiser at bitwagon dot com @ 2015-07-14 23:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66874
           Summary: RFE: x86_64_fallback_frame_state more robust
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jreiser at bitwagon dot com
  Target Milestone: ---

In libgcc/config/i386/linux-unwind.h function x86_64_fallback_frame_state()
please check the value of pc before accessing memory in the statement:
-----
  unsigned char *pc = context->ra;
      // snip
  if (*(unsigned char *)(pc+0) == 0x48
      && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
-----
I have seen pc values of 0, 2, 0xffffffff, etc due to missing or incorrect
debug info, particularly when the code that is being unwound was compiled with
no frame pointer, or was compiled by other compilers.  The result is SIGSEGV,
which is a major disappointment.

I suggest a check in the spirit of:
    if ((unsigned long)pc < 4096)
         return _URC_END_OF_STACK;
or similar.  Obviously this is heuristic, but it is much better than SIGSEGV.


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

* [Bug libgcc/66874] RFE: x86_64_fallback_frame_state more robust
  2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
@ 2015-07-15  3:04 ` hjl.tools at gmail dot com
  2024-02-23 17:19 ` [Bug target/66874] " sjames at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: hjl.tools at gmail dot com @ 2015-07-15  3:04 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-15
                 CC|                            |hjl.tools at gmail dot com
     Ever confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
I have seen bogus PC like 0xffffffb2 on i386:

https://sourceware.org/bugzilla/show_bug.cgi?id=18635


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

* [Bug target/66874] RFE: x86_64_fallback_frame_state more robust
  2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
  2015-07-15  3:04 ` [Bug libgcc/66874] " hjl.tools at gmail dot com
@ 2024-02-23 17:19 ` sjames at gcc dot gnu.org
  2024-02-23 17:24 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-23 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

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

--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
I've been going crazy hitting this recently (see e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114068#c2).

pinskia pointed me here and I fear I might be hitting this as a result of dwz
optimised debug info on gcc (as it's the only recent change I can think of).

Anyway, this seems to help indeed:

--- a/libgcc/config/i386/linux-unwind.h
+++ b/libgcc/config/i386/linux-unwind.h
@@ -60,6 +60,11 @@ x86_64_fallback_frame_state (struct _Unwind_Context
*context,
 #else
 #define RT_SIGRETURN_SYSCALL   0x050f40000201c0c7ULL
 #endif
+
+  /* Defend against corrupted PC, PR66874 */
+  if ((unsigned long)pc < 4096)
+    return _URC_END_OF_STACK;
+
   if (*(unsigned char *)(pc+0) == 0x48
       && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
     {

I've only shoved it in quickly to be able to debug something else so it's not
really ready to submit.

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

* [Bug target/66874] RFE: x86_64_fallback_frame_state more robust
  2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
  2015-07-15  3:04 ` [Bug libgcc/66874] " hjl.tools at gmail dot com
  2024-02-23 17:19 ` [Bug target/66874] " sjames at gcc dot gnu.org
@ 2024-02-23 17:24 ` jakub at gcc dot gnu.org
  2024-02-23 17:25 ` sjames at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-23 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Sam James from comment #2)
> I've been going crazy hitting this recently (see e.g.
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114068#c2).
> 
> pinskia pointed me here and I fear I might be hitting this as a result of
> dwz optimised debug info on gcc (as it's the only recent change I can think
> of).

How could dwz have anything to do with this?  The libgcc unwinder works on
.eh_frame sections.  dwz only ever modifies .debug_* sections (and
.gnu_debugaltlink and
perhaps throws away .gdb_index), all non-allocatable sections which the libgcc
unwinder never touches.

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

* [Bug target/66874] RFE: x86_64_fallback_frame_state more robust
  2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
                   ` (2 preceding siblings ...)
  2024-02-23 17:24 ` jakub at gcc dot gnu.org
@ 2024-02-23 17:25 ` sjames at gcc dot gnu.org
  2024-02-23 19:39 ` schwab@linux-m68k.org
  2024-02-26 15:08 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-23 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
I was just going off "incorrect debug info" in comment 0 given it's the only
thing I changed recently. If not, then I've got no idea.

If I were sure it were dwz, I'd file a bug there ;)

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

* [Bug target/66874] RFE: x86_64_fallback_frame_state more robust
  2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
                   ` (3 preceding siblings ...)
  2024-02-23 17:25 ` sjames at gcc dot gnu.org
@ 2024-02-23 19:39 ` schwab@linux-m68k.org
  2024-02-26 15:08 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2024-02-23 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
If the unwinder crashes you have either incorrect unwind info or a corrupted
stack.  Neither should be papered over.

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

* [Bug target/66874] RFE: x86_64_fallback_frame_state more robust
  2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
                   ` (4 preceding siblings ...)
  2024-02-23 19:39 ` schwab@linux-m68k.org
@ 2024-02-26 15:08 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-26 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
Pretty sure my issue is indeed PR114116.

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

end of thread, other threads:[~2024-02-26 15:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 23:58 [Bug libgcc/66874] New: RFE: x86_64_fallback_frame_state more robust jreiser at bitwagon dot com
2015-07-15  3:04 ` [Bug libgcc/66874] " hjl.tools at gmail dot com
2024-02-23 17:19 ` [Bug target/66874] " sjames at gcc dot gnu.org
2024-02-23 17:24 ` jakub at gcc dot gnu.org
2024-02-23 17:25 ` sjames at gcc dot gnu.org
2024-02-23 19:39 ` schwab@linux-m68k.org
2024-02-26 15:08 ` sjames 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).