[Bug gdb/19061] New: gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] New: gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

            Bug ID: 19061
           Summary: gdb-7.10 hangs/spins-on-cpu when debugging any program
                    on Alpha
           Product: gdb
           Version: 7.10
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: klausman-glibc at schwarzvogel dot de
  Target Milestone: ---

7.9.1 works fine:

$ gdb /bin/ls
GNU gdb (Gentoo 7.9.1 vanilla) 7.9.1
[...]
This GDB was configured as "alpha-unknown-linux-gnu".
Reading symbols from /bin/ls...(no debugging symbols found)...done.
(gdb) run
Starting program: /bin/ls
4405_alpha-sysctl-uac.patch      gcc-4.6.3.tbz2            secfix.patch
[...]
[Inferior 1 (process 27877) exited normally]
(gdb) quit

7.10:
gdb-7.10 $ gdb/gdb /bin/ls
GNU gdb (7.10-vanilla) 7.10
This GDB was configured as "alpha-unknown-linux-gnu".
Reading symbols from /bin/ls...(no debugging symbols found)...done.
(gdb) run
Starting program: /bin/ls
[gdb hangs here, eating close to 100% of one CPU. straceing it yields nothing
immediately obvious.]

So I bisected this from the tagged gdb-7.xy-release commits, using the example
above as a test case. I found was this commit to be the first bad one:

faf09f0119da40d9b408021ad5665a906e00ee59 is the first bad commit
commit faf09f0119da40d9b408021ad5665a906e00ee59
Author: Pedro Alves <[hidden email]>
Date:   Wed Mar 4 20:41:16 2015 +0000

    Linux native: Use TRAP_BRKPT/TRAP_HWBPT

    This patch adjusts the native Linux target backend to tell the core
    whether a trap was caused by a breakpoint.

    It teaches the target to get that information out of the si_code of
    the SIGTRAP siginfo.

    Tested on x86-64 Fedora 20, s390 RHEL 7, and PPC64 Fedora 18.  An
    earlier version was tested on ARM Fedora 21.

    gdb/ChangeLog:
    2015-03-04  Pedro Alves  <[hidden email]>

        * linux-nat.c (save_sigtrap): Check for breakpoints before
        checking watchpoints.
        (status_callback) [USE_SIGTRAP_SIGINFO]: Don't check whether a
        breakpoint is inserted if relying on SIGTRAP's siginfo.si_code.
        (check_stopped_by_breakpoint) [USE_SIGTRAP_SIGINFO]: Decide whether
        a breakpoint triggered based on the SIGTRAP's siginfo.si_code.
        (linux_nat_stopped_by_sw_breakpoint)
        (linux_nat_supports_stopped_by_sw_breakpoint)
        (linux_nat_stopped_by_hw_breakpoint)
        (linux_nat_supports_stopped_by_hw_breakpoint): New functions.
        (linux_nat_wait_1): Don't re-increment the PC if relying on
        SIGTRAP's siginfo->si_code.
        (linux_nat_add_target): Install new target methods.
        * linux-thread-db.c (check_event): Don't account for breakpoint PC
        offset if the target already adjusted the PC.
        * nat/linux-ptrace.h (USE_SIGTRAP_SIGINFO): New.
        (GDB_ARCH_TRAP_BRKPT): New.
        (TRAP_HWBKPT): Define if not already defined.

:040000 040000 5623811c697afc352ad61c2090773eacf8b4fbbc
206b4d6974c8a35cbada87c5c9555e8558a798e4 M      gdb


I am unsure how to dig out the actual problem from this, but I can provide
access to an Alpha machine if need be.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

Mike Frysinger <vapier at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |toolchain at gentoo dot org
               Host|                            |alpha-linux-gnu
           Assignee|unassigned at sourceware dot org   |palves at redhat dot com

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

Matt Turner <mattst88 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mattst88 at gmail dot com

--- Comment #1 from Matt Turner <mattst88 at gmail dot com> ---
Pedro, do you expect you're going to look at this bug sometime soon?

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #2 from Pedro Alves <palves at redhat dot com> ---
I won't be able to look at this myself in the near future, sorry.

The comments in the commit itself should provide hints:

 https://sourceware.org/ml/gdb-patches/2015-02/msg00731.html

as well as the series intro:

 https://sourceware.org/ml/gdb-patches/2015-02/msg00726.html


See also these later fixes for MIPS:

 https://sourceware.org/ml/gdb-patches/2016-02/msg00734.html

 https://sourceware.org/ml/gdb-patches/2016-02/msg00762.html

basically, the MIPS kernel didn't report si_code correctly.

Likely Alpha has some similar issue.

"set debug infrun 1" and "set debug lin-lwp 1" will likely show what kind of
loop gdb is stuck in.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #3 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
This is a somewhat representative slice of a spinning gdb run:

infrun: prepare_to_wait
linux_nat_wait: [process -1], [TARGET_WNOHANG]
RSRL: NOT resuming LWP process 2636, not stopped
LLW: enter
LNW: waitpid(-1, ...) returned 2636, ERRNO-OK
LLW: waitpid 2636 received Trace/breakpoint trap (stopped)
CSBB: process 2636 stopped by software breakpoint
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: NOT resuming LWP process 2636, has pending status
LLW: trap ptid is process 2636.
LLW: exit
infrun: target_wait (-1.0.0, status) =
infrun:   2636.2636.0 [process 2636],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x20000011d20
infrun: BPSTAT_WHAT_SINGLE
infrun: no stepping, continue
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun:   process 2636 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun:   process 2636 not executing
infrun: stop_all_threads done
infrun: skipping breakpoint: stepping past insn at: 0x20000011d20
infrun: skipping breakpoint: stepping past insn at: 0x20000011d20
infrun: skipping breakpoint: stepping past insn at: 0x20000011d20
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread
[process 2636] at 0x20000011d20
LLR: Preparing to step process 2636, 0, inferior_ptid process 2636
LLR: PTRACE_SINGLESTEP process 2636, 0 (resume event thread)
sigchld
infrun: prepare_to_wait
linux_nat_wait: [process -1], [TARGET_WNOHANG]
RSRL: NOT resuming LWP process 2636, not stopped
LLW: enter
LNW: waitpid(-1, ...) returned 2636, ERRNO-OK
LLW: waitpid 2636 received Trace/breakpoint trap (stopped)
CSBB: process 2636 stopped by software breakpoint
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: NOT resuming LWP process 2636, has pending status
LLW: trap ptid is process 2636.
LLW: exit
infrun: target_wait (-1.0.0, status) =
infrun:   2636.2636.0 [process 2636],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: clear_step_over_info
infrun: restart threads: [process 2636] is event thread
infrun: stop_pc = 0x20000003428
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread
[process 2636] at 0x20000003428
LLR: Preparing to resume process 2636, 0, inferior_ptid process 2636
LLR: PTRACE_CONT process 2636, 0 (resume event thread)
sigchld
infrun: prepare_to_wait
linux_nat_wait: [process -1], [TARGET_WNOHANG]
RSRL: NOT resuming LWP process 2636, not stopped
LLW: enter
LNW: waitpid(-1, ...) returned 2636, ERRNO-OK
LLW: waitpid 2636 received Trace/breakpoint trap (stopped)
CSBB: process 2636 stopped by software breakpoint
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: NOT resuming LWP process 2636, has pending status
LLW: trap ptid is process 2636.
LLW: exit
infrun: target_wait (-1.0.0, status) =
infrun:   2636.2636.0 [process 2636],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x20000011d20

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #4 from Pedro Alves <palves at redhat dot com> ---
We see:

 LLR: Preparing to step process 2636, 0, inferior_ptid process 2636
 LLR: PTRACE_SINGLESTEP process 2636, 0 (resume event thread)
 ...
 LLW: waitpid 2636 received Trace/breakpoint trap (stopped)
 CSBB: process 2636 stopped by software breakpoint
 ...
 infrun: stop_pc = 0x20000003428
 infrun: delayed software breakpoint trap, ignoring

And Alpha is a decr_pc_after_break arch:

 $ grep decr_pc_after *  | grep alpha
 alpha-tdep.c:  set_gdbarch_decr_pc_after_break (gdbarch, ALPHA_INSN_SIZE);

If GDB got that "stopped by software breakpoint" stop reason wrong, it will
decrement the thread's PC by ALPHA_INSN_SIZE when it shouldn't.  Then the next
time the thread is resumed, it executes the wrong instruction, in turn
manifesting in odd things like odd loops and crashes.

See linux-nat.c:save_stop_reason for where the PC is decremented.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|palves at redhat dot com           |unassigned at sourceware dot org

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

Richard Henderson <rth at gcc dot gnu.org> changed:

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

--- Comment #5 from Richard Henderson <rth at gcc dot gnu.org> ---
Created attachment 9593
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9593&action=edit
proposed patch

I tried with just the nat/linux-ptrace.h hunk, but that wasn't enough
to fix the problem.  We could fix the kernel side to distinguish, but
that gets into version requirements.  It might just be better not to
rely on the kernel for singlestep support at all.

Note that the base alpha_software_single_step should have been using
alpha_deal_with_atomic_sequence, so that we don't get into a different
sort of infinite loop.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #6 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
(In reply to Richard Henderson from comment #5)

> Created attachment 9593 [details]
> proposed patch
>
> I tried with just the nat/linux-ptrace.h hunk, but that wasn't enough
> to fix the problem.  We could fix the kernel side to distinguish, but
> that gets into version requirements.  It might just be better not to
> rely on the kernel for singlestep support at all.
>
> Note that the base alpha_software_single_step should have been using
> alpha_deal_with_atomic_sequence, so that we don't get into a different
> sort of infinite loop.

I applied this patch to 7.12 on our dev alpha, but it now hangs:


(gdb) set debug infrun 1
(gdb) set debug lin-lwp 1
(gdb) run
Starting program: /bin/ls
linux_nat_wait: [process 8646], []
LLW: enter
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: NOT resuming LWP process 8646, not stopped
LNW: about to sigsuspend
[no more output]

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #7 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
I *think* this may be fixed in gdb-8. I just checked out gdb-8.0.1-release from
git and I have been unable to reproduce the hang. I will keep using it for
everyday stuff and report back if anything breaks.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #8 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
(In reply to Tobias Klausmann from comment #7)
> I *think* this may be fixed in gdb-8. I just checked out gdb-8.0.1-release
> from git and I have been unable to reproduce the hang. I will keep using it
> for everyday stuff and report back if anything breaks.

I spoke too soon: I can now reliably make it hang on commit gdb-8.0.1-release
aka 2dcf9205c32aa69c102640962ff03746d04c02cc using ls or a trivial hello world
program.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pedro Alves <[hidden email]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=68f81d60196eb201b209873cf53258f13b0046b9

commit 68f81d60196eb201b209873cf53258f13b0046b9
Author: Richard Henderson <[hidden email]>
Date:   Fri Dec 15 18:19:42 2017 +0000

    Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha

    This fixes PR19061, where gdb hangs/spins-on-cpu when debugging any
    program on Alpha.

    (This patch is Uros' forward port of the patch from comment #5
    of the PR [1].)

    Patch was tested on alphaev68-linux-gnu, also tested with gcc's
    testsuite, where it fixed all hangs in guality.exp and
    simulate-thread.exp testcases.

    [1] https://sourceware.org/bugzilla/show_bug.cgi?id=19061#c5

    gdb/ChangeLog:
    2017-12-15  Richard Henderson  <[hidden email]>
            Uros Bizjak  <[hidden email]>

        PR gdb/19061
        * alpha-tdep.c (alpha_software_single_step): Call
        alpha_deal_with_atomic_sequence here.
        (set_gdbarch_software_single_step): Set to
        alpha_software_single_step.
        * nat/linux-ptrace.h [__alpha__]: Define GDB_ARCH_IS_TRAP_BRKPT
        and GDB_ARCH_IS_TRAP_HWBKPT.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

--- Comment #10 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.0-branch branch has been updated by Pedro Alves
<[hidden email]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bd496067387a9c89a7e62bbba76e784634936932

commit bd496067387a9c89a7e62bbba76e784634936932
Author: Richard Henderson <[hidden email]>
Date:   Wed Jan 3 15:14:12 2018 +0000

    Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha

    This fixes PR19061, where gdb hangs/spins-on-cpu when debugging any
    program on Alpha.

    (This patch is Uros' forward port of the patch from comment #5
    of the PR [1].)

    Patch was tested on alphaev68-linux-gnu, also tested with gcc's
    testsuite, where it fixed all hangs in guality.exp and
    simulate-thread.exp testcases.

    [1] https://sourceware.org/bugzilla/show_bug.cgi?id=19061#c5

    gdb/ChangeLog:
    2018-01-03  Richard Henderson  <[hidden email]>
            Uros Bizjak  <[hidden email]>

        PR gdb/19061
        * alpha-tdep.c (alpha_deal_with_atomic_sequence): Change
        prototype.
        (alpha_software_single_step): Call alpha_deal_with_atomic_sequence
        here.
        (set_gdbarch_software_single_step): Set to
        alpha_software_single_step.
        * nat/linux-ptrace.h [__alpha__]: Define GDB_ARCH_IS_TRAP_BRKPT
        and GDB_ARCH_IS_TRAP_HWBKPT.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/19061] gdb-7.10 hangs/spins-on-cpu when debugging any program on Alpha

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=19061

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |palves at redhat dot com
         Resolution|---                         |FIXED
   Target Milestone|---                         |8.1

--- Comment #11 from Pedro Alves <palves at redhat dot com> ---
Closing.

--
You are receiving this mail because:
You are on the CC list for the bug.