mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
The previous commit added a type trait which identifies types that should not be used within Python objects, that is, types that are not trivially default constructible. As a result of this, it was discovered that pending_frame_object includes a frame_info_ptr field. The problem with frame_info_ptr is that its constructor registers the new frame_info_ptr with the global frame_list. It is by this registration that invalidation of frame_info_ptr objects is performed. As Python is written in C, C++ constructors are not called, so when a pending_frame_object is created the constructor for the nested frame_info_ptr field is never run, and the frame_info_ptr is never registered with the global frame_list. As a result the frame_info_ptr will never be invalidated if the frame cache is flushed, this can then lead to problems where we make use of the 'frame_info *' within the frame_info_ptr, even though it is no longer valid. In this commit I change the frame_info_ptr within pending_frame_object to a 'frame_info_ptr *' and allocate the frame_info_ptr object on the heap, releasing the object, and resetting the point to NULL, when we are done with it. As the pending_frame_object only needs to remain valid for the duration of frame_unwind_python::sniff, the 'new' and 'delete' both performed within the function. We can now check that a pending_frame_object is valid by checking if the 'frame_info_ptr *' is NULL or not. As the frame_info_ptr is created in a valid state, and the point is set back to NULL when we are done with it, we no longer need to compare the frame_info_ptr object itself against NULL. The remaining changes in this patch are to dereference the 'frame_info_ptr *' in places where we need the actual object. In some cases I need to move the dereference later within a function, after a validity check, in order to avoid dereferencing a NULL pointer. Finally, I can add the static_assert that guarantees that pending_frame_object is now safe for allocation by Python. I discovered this bug while looking at PR gdb/32120. That bug is about a user's custom frame unwinder that triggers a flush of the frame cache during the sniffer phase (the RemoteTargetConnection.send_packet call switches thread, which triggers the frame cache flush). While looking at that bug I noticed that the frame_info_ptr within the pending_frame_object wasn't being reset when the frame cache was flushed. Fixing this does not resolve the user's issue, but I thought it was still worth tagging this commit with the bug link. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32120 Approved-By: Tom Tromey <tom@tromey.com> |
||
|---|---|---|
| .. | ||
| lib/gdb | ||
| py-all-events.def | ||
| py-arch.c | ||
| py-auto-load.c | ||
| py-block.c | ||
| py-bpevent.c | ||
| py-breakpoint.c | ||
| py-cmd.c | ||
| py-color.c | ||
| py-color.h | ||
| py-connection.c | ||
| py-continueevent.c | ||
| py-corefile.c | ||
| py-dap.c | ||
| py-disasm.c | ||
| py-event-types.def | ||
| py-event.c | ||
| py-event.h | ||
| py-events.h | ||
| py-evtregistry.c | ||
| py-evts.c | ||
| py-exitedevent.c | ||
| py-finishbreakpoint.c | ||
| py-frame.c | ||
| py-framefilter.c | ||
| py-function.c | ||
| py-gdb-readline.c | ||
| py-inferior.c | ||
| py-infevents.c | ||
| py-infthread.c | ||
| py-instruction.c | ||
| py-instruction.h | ||
| py-lazy-string.c | ||
| py-linetable.c | ||
| py-membuf.c | ||
| py-mi.c | ||
| py-micmd.c | ||
| py-newobjfileevent.c | ||
| py-obj-type.c | ||
| py-obj-type.h | ||
| py-objfile.c | ||
| py-param.c | ||
| py-prettyprint.c | ||
| py-progspace.c | ||
| py-record-btrace.c | ||
| py-record-btrace.h | ||
| py-record-full.c | ||
| py-record-full.h | ||
| py-record.c | ||
| py-record.h | ||
| py-ref.h | ||
| py-registers.c | ||
| py-signalevent.c | ||
| py-stopevent.c | ||
| py-stopevent.h | ||
| py-style.c | ||
| py-symbol.c | ||
| py-symtab.c | ||
| py-threadevent.c | ||
| py-tui.c | ||
| py-type.c | ||
| py-uiout.h | ||
| py-unwind.c | ||
| py-utils.c | ||
| py-value.c | ||
| py-varobj.c | ||
| py-xmethods.c | ||
| python-config.py | ||
| python-internal.h | ||
| python-limited-api-missing.h | ||
| python-traits.h | ||
| python.c | ||
| python.h | ||