From owner-freebsd-hackers Thu Jan 4 19:22:52 2001 From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 19:22:48 2001 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from phnxpop2.phnx.uswest.net (phnxpop2.phnx.uswest.net [206.80.192.2]) by hub.freebsd.org (Postfix) with SMTP id E1B5537B400 for ; Thu, 4 Jan 2001 19:22:47 -0800 (PST) Received: (qmail 11995 invoked by uid 0); 5 Jan 2001 03:22:46 -0000 Received: from ndslppp221.phnx.uswest.net (HELO pinyon.org) (63.224.136.221) by phnxpop2.phnx.uswest.net with SMTP; 5 Jan 2001 03:22:46 -0000 Received: from chomsky.Pinyon.ORG (localhost [127.0.0.1]) by pinyon.org (Postfix) with ESMTP id 62E3D8F; Thu, 4 Jan 2001 20:22:46 -0700 (MST) Date: Thu, 04 Jan 2001 20:22:46 -0700 Message-Id: <20010105032246.62E3D8F@pinyon.org> From: "Russell L. Carter" To: "John Polstra" Cc: hackers@FreeBSD.ORG X-Mailer: exmh version 2.1.1 10/15/1999 Subject: Re: ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/rtld.c:2033 In-Reply-To: Message from John Polstra of "Thu, 04 Jan 2001 16:26:30 PST." <200101050026.f050QU703172@vashon.polstra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG %In article <20001230164716.6366F9B@pinyon.org>, %Russell L. Carter wrote: %> %> Bingo! %> %> Thanks guys! % %Not so fast there, fella. You're not getting off that easily. ;-) %Could you please try the patch below? It is like the patch that Paul %sent, except it should handle error conditions better. % %This patch is against -current, but I think it will apply cleanly to %-stable too. My pleasure. This patch applies cleanly against a two day old -stable, and works just as well as the first patch, i.e., my program works as expected. Thanks! Russell %Thanks, %John % %Index: rtld.c %=================================================================== %RCS file: /home/ncvs/src/libexec/rtld-elf/rtld.c,v %retrieving revision 1.50 %diff -u -r1.50 rtld.c %--- rtld.c 2000/11/07 22:41:53 1.50 %+++ rtld.c 2001/01/05 00:13:18 %@@ -77,6 +77,8 @@ % static Obj_Entry *digest_phdr(const Elf_Phdr *, int, caddr_t, const char *); % static Obj_Entry *dlcheck(void *); % static bool donelist_check(DoneList *, const Obj_Entry *); %+static void errmsg_restore(char *); %+static char *errmsg_save(void); % static char *find_library(const char *, const Obj_Entry *); % static const char *gethints(void); % static void init_dag(Obj_Entry *); %@@ -457,6 +459,30 @@ % va_end(ap); % } % %+/* %+ * Return a dynamically-allocated copy of the current error message, if any. %+ */ %+static char * %+errmsg_save(void) %+{ %+ return error_message == NULL ? NULL : xstrdup(error_message); %+} %+ %+/* %+ * Restore the current error message from a copy which was previously saved %+ * by errmsg_save(). The copy is freed. %+ */ %+static void %+errmsg_restore(char *saved_msg) %+{ %+ if (saved_msg == NULL) %+ error_message = NULL; %+ else { %+ _rtld_error("%s", saved_msg); %+ free(saved_msg); %+ } %+} %+ % static const char * % basename(const char *name) % { %@@ -696,7 +722,7 @@ % if (obj == (Obj_Entry *) handle) % break; % %- if (obj == NULL || obj->dl_refcount == 0) { %+ if (obj == NULL || obj->refcount == 0 || obj->dl_refcount == 0) { % _rtld_error("Invalid shared object handle %p", handle); % return NULL; % } %@@ -1184,13 +1210,20 @@ % objlist_call_fini(Objlist *list) % { % Objlist_Entry *elm; %+ char *saved_msg; % %+ /* %+ * Preserve the current error message since a fini function might %+ * call into the dynamic linker and overwrite it. %+ */ %+ saved_msg = errmsg_save(); % STAILQ_FOREACH(elm, list, link) { % if (elm->obj->refcount == 0) { % dbg("calling fini function for %s", elm->obj->path); % (*elm->obj->fini)(); % } % } %+ errmsg_restore(saved_msg); % } % % /* %@@ -1202,11 +1235,18 @@ % objlist_call_init(Objlist *list) % { % Objlist_Entry *elm; %+ char *saved_msg; % %+ /* %+ * Preserve the current error message since an init function might %+ * call into the dynamic linker and overwrite it. %+ */ %+ saved_msg = errmsg_save(); % STAILQ_FOREACH(elm, list, link) { % dbg("calling init function for %s", elm->obj->path); % (*elm->obj->init)(); % } %+ errmsg_restore(saved_msg); % } % % static void %@@ -2030,7 +2070,8 @@ % { % const Needed_Entry *needed; % %- assert(root->refcount != 0); %+ if (root->refcount == 0) %+ return; % root->refcount--; % if (root->refcount == 0) % for (needed = root->needed; needed != NULL; needed = needed->next) % % %To Unsubscribe: send mail to majordomo@FreeBSD.org %with "unsubscribe freebsd-hackers" in the body of the message % To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message