Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@codesourcery.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org, Doug Evans <dje@google.com>
Subject: Re: [for discussion] Update inferior address spaces
Date: Tue, 02 Mar 2010 17:41:00 -0000	[thread overview]
Message-ID: <20100302174144.GS9493@caradoc.them.org> (raw)
In-Reply-To: <201003021715.47165.pedro@codesourcery.com>

On Tue, Mar 02, 2010 at 05:15:47PM +0000, Pedro Alves wrote:
> > Also, I believe there's a double free in the existing code, fixed in
> > this patch.  For the shared address space case.
> 
> Hmm, yes, in the not-shared -> shared direction.  With the patch, it's
> now leaking in the shared -> not-shared direction, I think?  This
> function is missing one bit of info: if the previous target had a
> shared address space.  This would be simpler if address spaces were
> refcounted.  Hmm, maybe we could find a way to get rid of the need for
> this function instead?  Something to ponder about.  Anyway, a few
> leaks per session is much better than double free, so that's still an
> improvement.

Oh, I wasn't even thinking about changes of architecture.  I was
suggesting something much simpler: there's a double free when both
before and after versions used shared address space, because we always
free pspace->aspace, but we don't assign a shared object there.

If the gdbarch changes those properties, this is going to blow up.

> > This patch works around the bug, but I don't think it's right as-is.
> 
> I think it's still good.  I'd just drop the assertion, and maybe
> special case gdbarch_has_global_solist like remote_add_inferior.  But
> I can take care of that when I get a chance of testing with
> DICOS, if you prefer.

I think I've been confusing the two gdbarch hooks (global solist,
shared address space).  They looked too much alike yesterday...

Is this about right?

-- 
Daniel Jacobowitz
CodeSourcery

2010-03-02  Daniel Jacobowitz  <dan@codesourcery.com>

	* progspace.c (update_address_spaces): Update inferior address spaces
	also.

Index: progspace.c
===================================================================
RCS file: /cvs/src/src/gdb/progspace.c,v
retrieving revision 1.4
diff -u -p -r1.4 progspace.c
--- progspace.c	19 Jan 2010 09:39:12 -0000	1.4
+++ progspace.c	2 Mar 2010 17:40:56 -0000
@@ -430,24 +430,30 @@ void
 update_address_spaces (void)
 {
   int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch);
-  struct address_space *aspace = NULL;
   struct program_space *pspace;
+  struct inferior *inf;
 
   init_address_spaces ();
 
-  ALL_PSPACES (pspace)
+  if (shared_aspace)
     {
-      free_address_space (pspace->aspace);
-
-      if (shared_aspace)
-	{
-	  if (aspace == NULL)
-	    aspace = new_address_space ();
-	  pspace->aspace = aspace;
-	}
-      else
-	pspace->aspace = new_address_space ();
+      struct address_space *aspace = new_address_space ();
+      free_address_space (current_program_space->aspace);
+      ALL_PSPACES (pspace)
+	pspace->aspace = aspace;
     }
+  else
+    ALL_PSPACES (pspace)
+      {
+	free_address_space (pspace->aspace);
+	pspace->aspace = new_address_space ();
+      }
+
+  for (inf = inferior_list; inf; inf = inf->next)
+    if (gdbarch_has_global_solist (target_gdbarch))
+      inf->aspace = maybe_new_address_space ();
+    else
+      inf->aspace = inf->pspace->aspace;
 }
 
 /* Save the current program space so that it may be restored by a later


  reply	other threads:[~2010-03-02 17:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01 21:37 Daniel Jacobowitz
2010-03-02 17:16 ` Pedro Alves
2010-03-02 17:41   ` Daniel Jacobowitz [this message]
2010-03-02 17:52     ` Pedro Alves
2010-03-02 17:57       ` Daniel Jacobowitz
2010-03-02 18:51       ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100302174144.GS9493@caradoc.them.org \
    --to=dan@codesourcery.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox