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,