From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Paul Pluzhnikov <ppluzhnikov@google.com>, gdb@sourceware.org
Subject: Re: Solibs and objfile BFD ownership
Date: Wed, 29 Jul 2009 23:56:00 -0000 [thread overview]
Message-ID: <8ac60eac0907291656v13f568ebw4f3a2b9bb7c7223d@mail.gmail.com> (raw)
In-Reply-To: <20090728154001.GA19451@caradoc.them.org>
[-- Attachment #1: Type: text/plain, Size: 974 bytes --]
On Tue, Jul 28, 2009 at 8:40 AM, Daniel Jacobowitz<drow@false.org> wrote:
> clear_solib ();
> objfile_purge_solibs ();
>
> The problem with doing things in this order is that both the solib and
> the objfile have a reference to the same BFD. The solib is
> responsible for releasing it (OBJF_KEEPBFD). arm_objfile_data_cleanup
> accesses objfile->obfd during free_objfile, to find the number
> of sections; at that point it's already been free'd.
That is a problem.
> Any thoughts?
There doesn't appear to be a correct order of destruction :-(
Attached patch restores the original order, while still keeping
solib_unloaded observers from accessing danglig objfiles.
I do not know if there is a better way to fix this.
Tested on Linux/x86_64 with no new regressions.
Thanks,
--
Paul Pluzhnikov
2009-07-29 Paul Pluzhnikov <ppluzhnikov@google.com>
* solib.c (clear_solib): Rename to clear_solib_1
(clear_solib): New function.
(no_shared_libraries): Adjust.
[-- Attachment #2: gdb-clear-solib-20090729.txt --]
[-- Type: text/plain, Size: 2102 bytes --]
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.122
diff -u -p -u -r1.122 solib.c
--- solib.c 17 Jul 2009 17:08:23 -0000 1.122
+++ solib.c 29 Jul 2009 23:39:11 -0000
@@ -893,10 +893,8 @@ solib_name_from_address (CORE_ADDR addre
return (0);
}
-/* Called by free_all_symtabs */
-
-void
-clear_solib (void)
+static void
+clear_solib_1 (int notify_observers)
{
struct target_so_ops *ops = solib_ops (target_gdbarch);
@@ -928,7 +926,8 @@ clear_solib (void)
{
struct so_list *so = so_list_head;
so_list_head = so->next;
- observer_notify_solib_unloaded (so);
+ if (notify_observers)
+ observer_notify_solib_unloaded (so);
if (so->abfd)
remove_target_sections (so->abfd);
free_so (so);
@@ -937,6 +936,15 @@ clear_solib (void)
ops->clear_solib ();
}
+/* Called by free_all_symtabs */
+
+void
+clear_solib (void)
+{
+ clear_solib_1 (1);
+}
+
+
/* GLOBAL FUNCTION
solib_create_inferior_hook -- shared library startup support
@@ -1018,13 +1026,20 @@ sharedlibrary_command (char *args, int f
void
no_shared_libraries (char *ignored, int from_tty)
{
- /* The order of the two routines below is important: clear_solib notifies
- the solib_unloaded observers, and some of these observers might need
- access to their associated objfiles. Therefore, we can not purge the
- solibs' objfiles before clear_solib has been called. */
+ struct so_list *so = so_list_head;
+
+ /* We notify all solib_unloaded observers before destroying any objfiles,
+ because some observers need access to their associated objfiles. */
+
+ for (so = so_list_head; so; so = so->next)
+ observer_notify_solib_unloaded (so);
+
+ /* The order of the two routines below is important: clear_solib_1
+ will free/close objfile->obfd (solib owns it), but objfile_purge_solibs
+ needs access to it (at least on ARM, see arm_objfile_data_cleanup). */
- clear_solib ();
objfile_purge_solibs ();
+ clear_solib_1 (0);
}
static void
next prev parent reply other threads:[~2009-07-29 23:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-28 15:40 Daniel Jacobowitz
2009-07-29 23:56 ` Paul Pluzhnikov [this message]
2009-07-30 16:16 ` Tom Tromey
2009-08-04 0:50 ` Paul Pluzhnikov
2009-08-04 14:53 ` Daniel Jacobowitz
2009-08-04 17:37 ` Paul Pluzhnikov
2009-08-04 18:40 ` Daniel Jacobowitz
2009-08-04 18:47 ` Paul Pluzhnikov
2009-08-18 5:56 ` Paul Pluzhnikov
2009-08-19 22:29 ` Tom Tromey
2009-08-20 1:50 ` Paul Pluzhnikov
2009-08-21 17:32 ` Tom Tromey
2009-08-21 18:04 ` Paul Pluzhnikov
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=8ac60eac0907291656v13f568ebw4f3a2b9bb7c7223d@mail.gmail.com \
--to=ppluzhnikov@google.com \
--cc=gdb@sourceware.org \
/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