binutils-gdb/gdb/python
Pedro Alves 3207396b95 Fix Python frame unwinder issue caught by Valgrind
Valgrind shows:

 ==17026== Invalid write of size 8
 ==17026==    at 0x54AA80: pending_frame_invalidate (py-unwind.c:477)
 ==17026==    by 0x5AB934: do_my_cleanups (cleanups.c:155)
 ==17026==    by 0x5AB9AF: do_cleanups (cleanups.c:177)
 ==17026==    by 0x54B009: pyuw_sniffer (py-unwind.c:606)
 ==17026==    by 0x755DAC: frame_unwind_try_unwinder (frame-unwind.c:105)
 ==17026==    by 0x755EEE: frame_unwind_find_by_frame (frame-unwind.c:160)
 ==17026==    by 0x750FFA: compute_frame_id (frame.c:454)
 ==17026==    by 0x753BD6: get_prev_frame_if_no_cycle (frame.c:1781)
 ==17026==    by 0x754292: get_prev_frame_always_1 (frame.c:1955)
 ==17026==    by 0x7542DA: get_prev_frame_always (frame.c:1971)
 ==17026==    by 0x7547BE: get_prev_frame (frame.c:2213)
 ==17026==    by 0x7532BD: unwind_to_current_frame (frame.c:1450)
 ==17026==  Address 0xd27b570 is 16 bytes inside a block of size 32 free'd
 ==17026==    at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==17026==    by 0x54B276: gdb_Py_DECREF (python-internal.h:185)
 ==17026==    by 0x54B298: py_decref (py-utils.c:34)
 ==17026==    by 0x5AB934: do_my_cleanups (cleanups.c:155)
 ==17026==    by 0x5AB9AF: do_cleanups (cleanups.c:177)
 ==17026==    by 0x54B009: pyuw_sniffer (py-unwind.c:606)
 ==17026==    by 0x755DAC: frame_unwind_try_unwinder (frame-unwind.c:105)
 ==17026==    by 0x755EEE: frame_unwind_find_by_frame (frame-unwind.c:160)
 ==17026==    by 0x750FFA: compute_frame_id (frame.c:454)
 ==17026==    by 0x753BD6: get_prev_frame_if_no_cycle (frame.c:1781)
 ==17026==    by 0x754292: get_prev_frame_always_1 (frame.c:1955)
 ==17026==    by 0x7542DA: get_prev_frame_always (frame.c:1971)
 ==17026==

Simply invalidate the object before releasing it.

gdb/ChangeLog:
2015-08-13  Pedro Alves  <palves@redhat.com>

	* python/py-unwind.c (pyuw_sniffer): Install the invalidate
	cleanup after the decref cleanup, not before.
2015-08-13 18:56:42 +01:00
..
lib/gdb PR python/17136 2015-08-06 09:24:58 -07:00
py-arch.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-auto-load.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
py-block.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-bpevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-breakpoint.c Explicit locations: use new location API 2015-08-11 17:09:35 -07:00
py-cmd.c Remove --xdb 2015-04-11 19:49:03 +02:00
py-continueevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-event.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
py-event.h Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-events.h Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
py-evtregistry.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-evts.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
py-exitedevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-finishbreakpoint.c Explicit locations: introduce address locations 2015-08-11 17:09:35 -07:00
py-frame.c Add casts for legitimate integer to enum conversions 2015-08-06 17:22:49 -04:00
py-framefilter.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-function.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-gdb-readline.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-inferior.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-infevents.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-infthread.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-lazy-string.c PR python/18438 2015-05-26 16:13:04 -07:00
py-linetable.c python: fix Linetable case to LineTable in docstrings and comments 2015-08-04 09:50:53 -07:00
py-newobjfileevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-objfile.c Allow gdb to find debug symbols file by build-id for PE file format also 2015-06-15 12:10:55 +01:00
py-param.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-prettyprint.c PR python/18089 2015-04-28 21:53:54 -07:00
py-progspace.c Add support for writing unwinders in Python. 2015-04-01 11:49:12 -07:00
py-signalevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-stopevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-stopevent.h Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
py-symbol.c Add casts for legitimate integer to enum conversions 2015-08-06 17:22:49 -04:00
py-symtab.c python: fix Linetable case to LineTable in docstrings and comments 2015-08-04 09:50:53 -07:00
py-threadevent.c Fix redefinition errors in C++ mode 2015-02-11 11:20:21 +00:00
py-type.c Remove CHECK_TYPEDEF, use check_typedef instead 2015-07-14 16:42:16 -04:00
py-unwind.c Fix Python frame unwinder issue caught by Valgrind 2015-08-13 18:56:42 +01:00
py-utils.c Split TRY_CATCH into TRY + CATCH 2015-03-07 15:14:14 +00:00
py-value.c Remove CHECK_TYPEDEF, use check_typedef instead 2015-07-14 16:42:16 -04:00
py-varobj.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
py-xmethods.c PR python/18285 2015-04-29 13:24:21 -07:00
python-config.py Add support for Python 3. 2012-12-12 16:47:30 +00:00
python-internal.h Remove redundant include directives. 2015-06-24 13:52:29 +01:00
python.c Initialize `location' in gdbpy_decode_line 2015-08-12 11:31:24 -07:00
python.h Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00