From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21576 invoked by alias); 23 Apr 2010 21:47:46 -0000 Received: (qmail 21559 invoked by uid 22791); 23 Apr 2010 21:47:44 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Apr 2010 21:47:36 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3NLlZuj019124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 23 Apr 2010 17:47:35 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3NLlWKr031186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 23 Apr 2010 17:47:34 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o3NLlV98024501; Fri, 23 Apr 2010 23:47:31 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o3NLlVMI024500; Fri, 23 Apr 2010 23:47:31 +0200 Date: Fri, 23 Apr 2010 21:47:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org, Paul Pluzhnikov , Kevin Buettner Subject: Re: [RFC] Detect loops in the solib chain Message-ID: <20100423214731.GA23964@host0.dyn.jankratochvil.net> References: <20080718160210.66b480e9@mesquite.lan> <20080717220959.GA10652@caradoc.them.org> <20100409154123.GA8218@host0.dyn.jankratochvil.net> <20100409210255.GA26135@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00820.txt.bz2 On Fri, 23 Apr 2010 22:09:43 +0200, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil writes: > Jan> + # glibc debug info is not available and it is too difficult to find and > Jan> + # parse it from this testcase without the gdb supporting functions. > Jan> + xfail "$test (no _r_debug symbol)" > Jan> + untested ${testfile}.exp > Jan> + return > Jan> + } > Jan> + -re " = 0x\[0-9a-f\]+\r\n$gdb_prompt $" { > Jan> + pass $test > > I think it is preferable to have the test name the same, regardless of > whether it passes or xfails. Extra info can be logged with verbose. Changed. Although there are precedent cases of this, still they are therefore probably not considered as the preferred ones. Such as: gdb.base/corefile.exp set test "accessing mmapped data in core file" pass "$test" fail "$test (mapping failed at runtime)" fail "$test (mapping address not found in core file)" > This is ok with that change. Checked in. Thanks, Jan http://sourceware.org/ml/gdb-cvs/2010-04/msg00240.html --- src/gdb/ChangeLog 2010/04/23 18:09:16 1.11678 +++ src/gdb/ChangeLog 2010/04/23 21:44:19 1.11679 @@ -1,3 +1,14 @@ +2010-04-23 Daniel Jacobowitz + Paul Pluzhnikov + Jan Kratochvil + + Fix deadlock on looped list of loaded shared objects. + * solib-svr4.c (LM_PREV): New function. + (IGNORE_FIRST_LINK_MAP_ENTRY): Use it. + (svr4_current_sos): Check for correct l_prev. New variables prev_lm + and next_lm. Clear prev_lm for solib_svr4_r_ldsomap. + * config/djgpp/fnchange.lst: Add translation for solib-corrupted.exp. + 2010-04-23 Doug Evans * configure.ac (CONFIG_SRCS): Add py-auto-load.o even if not using --- src/gdb/solib-svr4.c 2010/03/11 22:07:02 1.130 +++ src/gdb/solib-svr4.c 2010/04/23 21:44:19 1.131 @@ -272,6 +272,16 @@ } static CORE_ADDR +LM_PREV (struct so_list *so) +{ + struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); + struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; + + return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset, + ptr_type); +} + +static CORE_ADDR LM_NAME (struct so_list *so) { struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); @@ -284,16 +294,12 @@ static int IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so) { - struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; - /* Assume that everything is a library if the dynamic loader was loaded late by a static executable. */ if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL) return 0; - return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset, - ptr_type) == 0; + return LM_PREV (so) == 0; } /* Per pspace SVR4 specific data. */ @@ -1101,7 +1107,7 @@ static struct so_list * svr4_current_sos (void) { - CORE_ADDR lm; + CORE_ADDR lm, prev_lm; struct so_list *head = 0; struct so_list **link_ptr = &head; CORE_ADDR ldsomap = 0; @@ -1120,6 +1126,7 @@ /* Walk the inferior's link map list, and build our list of `struct so_list' nodes. */ + prev_lm = 0; lm = solib_svr4_r_map (info); while (lm) @@ -1127,6 +1134,7 @@ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); struct so_list *new = XZALLOC (struct so_list); struct cleanup *old_chain = make_cleanup (xfree, new); + CORE_ADDR next_lm; new->lm_info = xmalloc (sizeof (struct lm_info)); make_cleanup (xfree, new->lm_info); @@ -1138,14 +1146,21 @@ read_memory (lm, new->lm_info->lm, lmo->link_map_size); - lm = LM_NEXT (new); + next_lm = LM_NEXT (new); + + if (LM_PREV (new) != prev_lm) + { + warning (_("Corrupted shared library list")); + free_so (new); + next_lm = 0; + } /* For SVR4 versions, the first entry in the link map is for the inferior executable, so we must ignore it. For some versions of SVR4, it has no name. For others (Solaris 2.3 for example), it does have a name, so we can no longer use a missing name to decide when to ignore it. */ - if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0) + else if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0) { info->main_lm_addr = new->lm_info->lm_addr; free_so (new); @@ -1182,12 +1197,18 @@ } } + prev_lm = lm; + lm = next_lm; + /* On Solaris, the dynamic linker is not in the normal list of shared objects, so make sure we pick it up too. Having symbol information for the dynamic linker is quite crucial for skipping dynamic linker resolver code. */ if (lm == 0 && ldsomap == 0) - lm = ldsomap = solib_svr4_r_ldsomap (info); + { + lm = ldsomap = solib_svr4_r_ldsomap (info); + prev_lm = 0; + } discard_cleanups (old_chain); } --- src/gdb/config/djgpp/fnchange.lst 2010/04/09 15:15:05 1.112 +++ src/gdb/config/djgpp/fnchange.lst 2010/04/23 21:44:19 1.113 @@ -397,6 +397,7 @@ @V@/gdb/testsuite/gdb.base/siginfo-obj.c @V@/gdb/testsuite/gdb.base/si-obj.c @V@/gdb/testsuite/gdb.base/siginfo-addr.exp @V@/gdb/testsuite/gdb.base/si-addr.exp @V@/gdb/testsuite/gdb.base/siginfo-obj.exp @V@/gdb/testsuite/gdb.base/si-obj.exp +@V@/gdb/testsuite/gdb.base/solib-corrupted.exp @V@/gdb/testsuite/gdb.base/so-crptd.exp @V@/gdb/testsuite/gdb.base/solib-disc.c @V@/gdb/testsuite/gdb.base/so-disc.c @V@/gdb/testsuite/gdb.base/solib-display-lib.c @V@/gdb/testsuite/gdb.base/so-displib.c @V@/gdb/testsuite/gdb.base/solib-display-main.c @V@/gdb/testsuite/gdb.base/so-dispmain.c --- src/gdb/testsuite/ChangeLog 2010/04/23 18:03:31 1.2252 +++ src/gdb/testsuite/ChangeLog 2010/04/23 21:44:20 1.2253 @@ -1,3 +1,8 @@ +2010-04-23 Jan Kratochvil + + Fix deadlock on looped list of loaded shared objects. + * gdb.base/solib-corrupted.exp: New. + 2010-04-23 Doug Evans * gdb.python/py-section-script.c: New file. --- src/gdb/testsuite/gdb.base/solib-corrupted.exp +++ src/gdb/testsuite/gdb.base/solib-corrupted.exp 2010-04-23 21:44:35.962406000 +0000 @@ -0,0 +1,46 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile "solib-corrupted" +set srcfile start.c + +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { + untested ${testfile}.exp + return -1 +} + +if ![runto_main] { + fail "Can't run to main" + return +} + +gdb_test "info sharedlibrary" "" "normal list" + +# GDB checks there for matching L_PREV. +set test "make solibs looping" +gdb_test_multiple "p/x _r_debug->r_map->l_next = _r_debug->r_map" $test { + -re "(No symbol \"_r_debug\" in current context\\.|Attempt to extract a component of a value that is not a structure pointer\\.)\r\n$gdb_prompt $" { + # glibc debug info is not available and it is too difficult to find and + # parse it from this testcase without the gdb supporting functions. + verbose -log "no _r_debug symbol has been found" + xfail $test + untested ${testfile}.exp + return + } + -re " = 0x\[0-9a-f\]+\r\n$gdb_prompt $" { + pass $test + } +} +gdb_test "info sharedlibrary" "warning: Corrupted shared library list\r\n.*" "corrupted list"