This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/22475] New: Python API: breakpoint subclass: GDB crashes if function called through parse_and_eval() exits


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

            Bug ID: 22475
           Summary: Python API: breakpoint subclass: GDB crashes if
                    function called through parse_and_eval() exits
           Product: gdb
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: michael.platzer at hotmail dot com
  Target Milestone: ---

Created attachment 10627
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10627&action=edit
The *.c and *.py files to reproduce the error.

OS: 4.13.11-1-ARCH x86_64 GNU/Linux

GDB version: GNU gdb (GDB) 8.0.1.20171108-git (local build)
GCC version: gcc (GCC) 7.2.0 (arch linux package)
Python version: Python 3.6.3 (arch linux package)

Note: GNU gdb (GDB) 8.0.1 (arch linux package) behaves identically

I execute GDB in batch mode, running a python script which uses a subclass of
gdb.Breakpoint; within the stop() method of this subclass, calling a function
in the executable (using gdb.parse_and_eval()) which in turn calls exit(3)
produces an assertion violation in thread.c:

../../gdb/thread.c:1123: internal-error: void finish_thread_state(ptid_t):
Assertion `tp' failed.


STEPS TO REPRODUCE:

1. Create a *.c and a *.py file, with following content:
--------------------------------------------------------------------------------
$ cat foo_exit.c
#include <stdlib.h>
void foo()
{
    exit(0);
}
int main(int argc, char *argv[])
{
    return 0;
}
$ cat bp_stop.py
import gdb

class MainBreak(gdb.Breakpoint):
    def stop(self):
        try:
            gdb.parse_and_eval('foo()')
        except gdb.error as err:
            print('caught gdb error: ' + str(err))

MainBreak('main')
gdb.execute('run')
--------------------------------------------------------------------------------

2. Compile the *.c file:
--------------------------------------------------------------------------------
$ gcc -g -o foo_exit foo_exit.c
--------------------------------------------------------------------------------

3. Run GDB:
--------------------------------------------------------------------------------
$ gdb --batch -x bp_stop.py foo_exit
Breakpoint 1 at 0x663: file foo_exit.c, line 8.
[Inferior 1 (process 3843) exited normally]
caught gdb error: The program being debugged exited while in a function called
from GDB.
Evaluation of the expression containing the function
(foo) will be abandoned.
../../gdb/thread.c:1123: internal-error: void finish_thread_state(ptid_t):
Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]

This is a bug, please report it.  For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.

../../gdb/thread.c:1123: internal-error: void finish_thread_state(ptid_t):
Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]
Aborted (core dumped)
--------------------------------------------------------------------------------

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]