This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/22474] New: Python API: stop event: GDB crashes if function called through parse_and_eval() exits
- From: "michael.platzer at hotmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 22 Nov 2017 09:52:30 +0000
- Subject: [Bug python/22474] New: Python API: stop event: GDB crashes if function called through parse_and_eval() exits
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=22474
Bug ID: 22474
Summary: Python API: stop event: 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 10626
--> https://sourceware.org/bugzilla/attachment.cgi?id=10626&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 an event
handler to catch stop events caused by breakpoints; within the event handler,
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:101: internal-error: thread_info* inferior_thread():
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
def stop_handler(ev):
if type(ev) is gdb.BreakpointEvent:
try:
gdb.parse_and_eval('foo()')
except gdb.error as err:
print('caught gdb error: ' + str(err))
gdb.events.stop.connect(stop_handler)
gdb.execute('break 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 3415) 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:101: internal-error: thread_info* inferior_thread():
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:101: internal-error: thread_info* inferior_thread():
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.