bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

segv in `info target': stale ptrs


From: Golubev I. N.
Subject: segv in `info target': stale ptrs
Date: Fri, 24 Aug 2001 10:29:16 (GMT)

Version: 5.0; should also be applicable at least to `solib.c' from 5.1

The bug report was posted on Fri, 07 Jul 2000 12:49:48 (GMT).

Segv described there is caused by attempts to print out stale pointers
(both `the_bfd_section' and 'bfd') in section arrays pointed to by
`to_sections' in `struct target_ops'.

Those stale pointers appear after `bfd_close <- free_so <-
clear_solib' call chain.  `free_so' description says:

> If we have placed SO's sections in some target's section table, the
> caller is responsible for removing them.

Various `clear_solib' implementations fail to comply.

        * solib.c (clear_solib): Call `remove_target_sections' to fix
        stale pointers in `struct target_ops'.
        * irix5-nat.c (clear_solib): Ditto.
        * osfsolib.c (clear_solib): Ditto.

--- solib.c     2001/08/24 07:57:42     1.1
+++ solib.c     2001/08/24 09:27:05
@@ -1591,7 +1591,11 @@
   while (so_list_head)
     {
       struct so_list *so = so_list_head;
+      bfd *abfd = so->abfd;
+
       so_list_head = so->next;
+      if (abfd)
+       remove_target_sections (abfd);
       free_so (so);
     }
 
--- irix5-nat.c 2001/08/24 08:44:43     1.1
+++ irix5-nat.c 2001/08/24 09:31:23
@@ -1066,14 +1066,17 @@
 
   while (so_list_head)
     {
+      bfd *abfd = so_list_head->abfd;
+
       if (so_list_head->sections)
        {
          free ((PTR) so_list_head->sections);
        }
-      if (so_list_head->abfd)
+      if (abfd)
        {
-         bfd_filename = bfd_get_filename (so_list_head->abfd);
-         if (!bfd_close (so_list_head->abfd))
+         remove_target_sections (abfd);
+         bfd_filename = bfd_get_filename (abfd);
+         if (!bfd_close (abfd))
            warning ("cannot close \"%s\": %s",
                     bfd_filename, bfd_errmsg (bfd_get_error ()));
        }
--- osfsolib.c  2001/08/24 08:53:15     1.1
+++ osfsolib.c  2001/08/24 09:32:58
@@ -819,14 +819,17 @@
 
   while (so_list_head)
     {
+      bfd *abfd = so_list_head->abfd;
+
       if (so_list_head->sections)
        {
          free ((PTR) so_list_head->sections);
        }
-      if (so_list_head->abfd)
+      if (abfd)
        {
-         bfd_filename = bfd_get_filename (so_list_head->abfd);
-         if (!bfd_close (so_list_head->abfd))
+         remove_target_sections (abfd);
+         bfd_filename = bfd_get_filename (abfd);
+         if (!bfd_close (abfd))
            warning ("cannot close \"%s\": %s",
                     bfd_filename, bfd_errmsg (bfd_get_error ()));
        }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]