From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6155 invoked by alias); 22 Jun 2006 11:40:36 -0000 Received: (qmail 6146 invoked by uid 22791); 22 Jun 2006 11:40:35 -0000 X-Spam-Check-By: sourceware.org Received: from ip-85-160-32-69.eurotel.cz (HELO host0.dyn.jankratochvil.net) (85.160.32.69) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 22 Jun 2006 11:40:26 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.13.6/8.13.4) with ESMTP id k5MBeIeQ021143 for ; Thu, 22 Jun 2006 13:40:19 +0200 Received: (from lace@localhost) by host0.dyn.jankratochvil.net (8.13.6/8.13.6/Submit) id k5MBeG33021142 for gdb-patches@sources.redhat.com; Thu, 22 Jun 2006 13:40:16 +0200 Date: Thu, 22 Jun 2006 11:40:00 -0000 From: Jan Kratochvil To: gdb-patches@sources.redhat.com Subject: [patch] Fixed occasional failure to load a custom shared library Message-ID: <20060622114016.GA21094@host0.dyn.jankratochvil.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00322.txt.bz2 --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 593 Hi, https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=146810 Inferior ENV{"LD_LIBRARY_PATH"} and/or ENV{"PATH"} may get ignored by solib_open() resulting in Error while mapping shared library sections: libc++test4dl.so: Success. and afterwards while calling a function from the shared library it crashes: (gdb) call randomthing() Program received signal SIGSEGV, Segmentation fault. randomthing () at c++test4dl.cxx:3 3 void randomthing() The program being debugged was signaled while in a function called from GDB. Trivia NULL vs. "" check issue. Regards, Jan Kratochvil --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="gdb-cvs20060621-solib_absolute_prefix_is_empty.patch" Content-length: 1927 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=146810 Bug is still present in 2006-06-21 GDB CVS. The segfault is just a consequence of earlier failure to properly load the custom shared library: Error while mapping shared library sections: libc++test4dl.so: Success. Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.84 diff -u -p -r1.84 solib.c --- solib.c 25 Feb 2006 04:36:39 -0000 1.84 +++ solib.c 22 Jun 2006 11:24:40 -0000 @@ -146,13 +146,17 @@ solib_open (char *in_pathname, char **fo int found_file = -1; char *temp_pathname = NULL; char *p = in_pathname; + int solib_absolute_prefix_is_empty; + + solib_absolute_prefix_is_empty = (!solib_absolute_prefix + || !*solib_absolute_prefix); while (*p && !IS_DIR_SEPARATOR (*p)) p++; if (*p) { - if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix == NULL) + if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix_is_empty) temp_pathname = in_pathname; else { @@ -208,14 +212,14 @@ solib_open (char *in_pathname, char **fo &temp_pathname); /* If not found, next search the inferior's $PATH environment variable. */ - if (found_file < 0 && solib_absolute_prefix == NULL) + if (found_file < 0 && solib_absolute_prefix_is_empty) found_file = openp (get_in_environ (inferior_environ, "PATH"), OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, 0, &temp_pathname); /* If not found, next search the inferior's $LD_LIBRARY_PATH environment variable. */ - if (found_file < 0 && solib_absolute_prefix == NULL) + if (found_file < 0 && solib_absolute_prefix_is_empty) found_file = openp (get_in_environ (inferior_environ, "LD_LIBRARY_PATH"), OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, 0, &temp_pathname); --lrZ03NoBR/3+SXJZ--