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.