public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/infcall: Fix freed frame dereferenced in inferior call
@ 2024-01-11 16:38 Toby Lloyd Davies
  2024-01-11 17:26 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Toby Lloyd Davies @ 2024-01-11 16:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Toby Lloyd Davies

Between the store to frame and it's use by get_frame_sp (frame) there is
a call to find_function_addr(). If the function is a IFUNC then this can
do another inferior call. This results in the frame cache being
invalidated which frees all frames. Then the frame pointer previously
stored is left dangling and get_frame_sp (frame) may segfault.
---
 gdb/infcall.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/infcall.c b/gdb/infcall.c
index 8252feea074..15dce04c984 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -938,6 +938,7 @@ call_function_by_hand_dummy (struct value *function,
 
   /* Ensure that the initial SP is correctly aligned.  */
   {
+    frame = get_current_frame ();
     CORE_ADDR old_sp = get_frame_sp (frame);
 
     if (gdbarch_frame_align_p (gdbarch))
-- 
2.34.1


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

end of thread, other threads:[~2024-01-11 18:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11 16:38 [PATCH] gdb/infcall: Fix freed frame dereferenced in inferior call Toby Lloyd Davies
2024-01-11 17:26 ` Tom Tromey
2024-01-11 18:19   ` Toby Lloyd Davies

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