public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb/gdb-7.12-branch] Fix python-interactive with Python 3.6
@ 2017-01-21  2:29 sergiodj+buildbot
  2017-01-21  2:29 ` Failures on Fedora-x86_64-native-gdbserver-m32, branch gdb-7.12-branch sergiodj+buildbot
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: sergiodj+buildbot @ 2017-01-21  2:29 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 3fc6097b073698a50d0ab70c6c8205a83cd9383c ***

Author: Simon Marchi <simon.marchi@ericsson.com>
Branch: gdb-7.12-branch
Commit: 3fc6097b073698a50d0ab70c6c8205a83cd9383c

Fix python-interactive with Python 3.6

New in v2:

 - Define PyMem_RawMalloc as PyMem_Malloc for Python < 3.4 and use
   PyMem_RawMalloc in the code.

Since Python 3.4, the callback installed in PyOS_ReadlineFunctionPointer
should return a value allocated with PyMem_RawMalloc instead of
PyMem_Malloc.  The reason is that PyMem_Malloc must be called with the
Python Global Interpreter Lock (GIL) held, which is not the case in the
context where this function is called.  PyMem_RawMalloc was introduced
for cases like this.

In Python 3.6, it looks like they added an assert to verify that
PyMem_Malloc was not called without the GIL.  The consequence is that
typing anything in the python-interactive mode of gdb crashes the
process.  The same behavior was observed with the official package on
Arch Linux as well as with a manual Python build on Ubuntu 14.04.

This is what is shown with a debug build of Python 3.6 (the error with a
non-debug build is far less clear):

  (gdb) pi
  >>> print(1)
  Fatal Python error: Python memory allocator called without holding the GIL

  Current thread 0x00007f1459af8780 (most recent call first):
  [1]    21326 abort      ./gdb

and the backtrace:

  #0  0x00007ffff618bc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
  #1  0x00007ffff618f028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
  #2  0x00007ffff6b104d6 in Py_FatalError (msg=msg@entry=0x7ffff6ba15b8 "Python memory allocator called without holding the GIL") at Python/pylifecycle.c:1457
  #3  0x00007ffff6a37a68 in _PyMem_DebugCheckGIL () at Objects/obmalloc.c:1972
  #4  0x00007ffff6a3804e in _PyMem_DebugFree (ctx=0x7ffff6e65290 <_PyMem_Debug+48>, ptr=0x24f8830) at Objects/obmalloc.c:1994
  #5  0x00007ffff6a38e1d in PyMem_Free (ptr=<optimized out>) at Objects/obmalloc.c:442
  #6  0x00007ffff6b866c6 in _PyFaulthandler_Fini () at ./Modules/faulthandler.c:1369
  #7  0x00007ffff6b104bd in Py_FatalError (msg=msg@entry=0x7ffff6ba15b8 "Python memory allocator called without holding the GIL") at Python/pylifecycle.c:1431
  #8  0x00007ffff6a37a68 in _PyMem_DebugCheckGIL () at Objects/obmalloc.c:1972
  #9  0x00007ffff6a37aa3 in _PyMem_DebugMalloc (ctx=0x7ffff6e65290 <_PyMem_Debug+48>, nbytes=5) at Objects/obmalloc.c:1980
  #10 0x00007ffff6a38d91 in PyMem_Malloc (size=<optimized out>) at Objects/obmalloc.c:418
  #11 0x000000000064dbe2 in gdbpy_readline_wrapper (sys_stdin=0x7ffff6514640 <_IO_2_1_stdin_>, sys_stdout=0x7ffff6514400 <_IO_2_1_stdout_>, prompt=0x7ffff4d4f7d0 ">>> ")
    at /home/emaisin/src/binutils-gdb/gdb/python/py-gdb-readline.c:75

The documentation is very clear about it [1] and it was also mentioned
in the "What's New In Python 3.4" page [2].

[1] https://docs.python.org/3/c-api/veryhigh.html#c.PyOS_ReadlineFunctionPointer
[2] https://docs.python.org/3/whatsnew/3.4.html#changes-in-the-c-api

gdb/ChangeLog:

	* python/python-internal.h (PyMem_RawMalloc): Define for
	Python < 3.4.
	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use
	PyMem_RawMalloc instead of PyMem_Malloc.


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

end of thread, other threads:[~2017-01-25  0:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-21  2:29 [binutils-gdb/gdb-7.12-branch] Fix python-interactive with Python 3.6 sergiodj+buildbot
2017-01-21  2:29 ` Failures on Fedora-x86_64-native-gdbserver-m32, branch gdb-7.12-branch sergiodj+buildbot
2017-01-21  2:42 ` Failures on Fedora-s390x-m64, " sergiodj+buildbot
2017-01-21  2:43 ` Failures on Fedora-x86_64-m32, " sergiodj+buildbot
2017-01-21  2:54 ` Failures on Fedora-x86_64-m64, " sergiodj+buildbot
2017-01-21  3:05 ` Failures on Ubuntu-AArch64-native-gdbserver-m64, " sergiodj+buildbot
2017-01-21  3:14 ` Failures on Fedora-x86_64-cc-with-index, " sergiodj+buildbot
2017-01-21  3:32 ` Failures on Debian-s390x-native-extended-gdbserver-m64, " sergiodj+buildbot
2017-01-21  4:18 ` Failures on Debian-s390x-m64, " sergiodj+buildbot
2017-01-25  0:24 ` Failures on Fedora-ppc64be-native-gdbserver-m64, " sergiodj+buildbot

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).