Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Andreas Schwab <schwab@redhat.com>
Cc: Pedro Alves <pedro@codesourcery.com>,
	gdb-patches@sourceware.org,
	        Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [patch] Fix for PR gdb/10819
Date: Thu, 22 Oct 2009 16:30:00 -0000	[thread overview]
Message-ID: <8ac60eac0910220929v4cad21b4gcf706be716b13771@mail.gmail.com> (raw)
In-Reply-To: <8ac60eac0910220833v96b75i379486328b8f7955@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

On Thu, Oct 22, 2009 at 8:33 AM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:

> I'll just fix the bsearch calls, since A) one of them is known to
> cause a problem and B) I introduced them recently :-(

Here is the revised patch.

The call to bsearch in dwarf2_frame_find_fde is already preceded by
assert of "fde_table->num_entries > 0", so no changes are needed there.

There is one more call to bsearch in solib-osf.c, but that file appears
to not be used anymore. Ok to deleted it?

Thanks,
-- 
Paul Pluzhnikov

2009-10-22  Paul Pluzhnikov  <ppluzhnikov@google.com>

      PR gdb/10819
      * dwarf2-frame.c (find_cie): Don't call bsearch on
      empty cie_table.
      * objfiles.c (find_pc_section): Likewise.

[-- Attachment #2: gdb-pr10819-20091022-2.txt --]
[-- Type: text/plain, Size: 1716 bytes --]

Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.100
diff -u -p -u -r1.100 dwarf2-frame.c
--- dwarf2-frame.c	6 Oct 2009 23:27:04 -0000	1.100
+++ dwarf2-frame.c	22 Oct 2009 16:21:17 -0000
@@ -1525,6 +1525,22 @@ find_cie (struct dwarf2_cie_table *cie_t
 {
   struct dwarf2_cie **p_cie;
 
+  if (cie_table->num_entries == 0)
+    {
+      gdb_assert (cie_table->entries == NULL);
+
+      /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
+	 bsearch be a valid pointer even when the NMEMB argument is 0.
+
+	 Passing NULL for BASE and 0 for NMEMB is also known to cause
+	 Solaris-8 bsearch to call bsearch_cie_cmp with NULL ELEMENT
+	 (which doesn't expect that and crashes); see PR gdb/10819.
+
+	 Therefore, avoid calling bsearch under these conditions.  */
+
+      return NULL;
+    }
+
   p_cie = bsearch (&cie_pointer, cie_table->entries, cie_table->num_entries,
                    sizeof (cie_table->entries[0]), bsearch_cie_cmp);
   if (p_cie != NULL)
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.99
diff -u -p -u -r1.99 objfiles.c
--- objfiles.c	19 Oct 2009 09:51:41 -0000	1.99
+++ objfiles.c	22 Oct 2009 16:21:17 -0000
@@ -1175,6 +1175,11 @@ find_pc_section (CORE_ADDR pc)
       pspace_info->objfiles_changed_p = 0;
     }
 
+  /* See comment in dwarf2-frame.c:find_cie on why this check
+     is necessary.  */
+  if (pspace_info->num_sections == 0)
+    return NULL;
+
   sp = (struct obj_section **) bsearch (&pc,
 					pspace_info->sections,
 					pspace_info->num_sections,

  reply	other threads:[~2009-10-22 16:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22  4:48 Paul Pluzhnikov
2009-10-22  5:48 ` Jan Kratochvil
2009-10-22  6:14   ` Paul Pluzhnikov
2009-10-22 10:43     ` Pedro Alves
2009-10-22 11:09       ` Andreas Schwab
2009-10-22 15:34         ` Paul Pluzhnikov
2009-10-22 16:30           ` Paul Pluzhnikov [this message]
2009-10-22 17:44             ` Tom Tromey
2009-10-22 18:31               ` Paul Pluzhnikov
2009-10-22 20:13                 ` Tom Tromey
2009-10-22 20:46                   ` Paul Pluzhnikov
2009-10-22 18:11     ` Pedro Alves

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=8ac60eac0910220929v4cad21b4gcf706be716b13771@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=pedro@codesourcery.com \
    --cc=schwab@redhat.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