aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-08-13 18:56:42 +0100
committerPedro Alves <palves@redhat.com>2015-08-13 18:56:42 +0100
commit3207396b9532f179bad24a9fb9a83253f3f5144d (patch)
tree6d9719683fdc1c9935d3d8973dbac92699236ae9
parent67994074671a31e3d2fb78f6036f38095211ac49 (diff)
downloadfsf-binutils-gdb-3207396b9532f179bad24a9fb9a83253f3f5144d.zip
fsf-binutils-gdb-3207396b9532f179bad24a9fb9a83253f3f5144d.tar.gz
fsf-binutils-gdb-3207396b9532f179bad24a9fb9a83253f3f5144d.tar.bz2
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.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/python/py-unwind.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f33faaa..7db4487 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+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 Pierre-Marie de Rodat <derodat@adacore.com>
* ada-lang.c: Include namespace.h
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index b6e8a75..18f8f4d 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -537,8 +537,8 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame,
goto error;
((pending_frame_object *) pyo_pending_frame)->gdbarch = gdbarch;
((pending_frame_object *) pyo_pending_frame)->frame_info = this_frame;
- make_cleanup (pending_frame_invalidate, (void *) pyo_pending_frame);
make_cleanup_py_decref (pyo_pending_frame);
+ make_cleanup (pending_frame_invalidate, (void *) pyo_pending_frame);
/* Run unwinders. */
if (gdb_python_module == NULL