X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=VyKqqo+J4yw6/7YCeakOZ1VfGTBUlKlviKrROCcfM/U=; b=V9W8wG3DWw9zxB4blBqVJIU44GOjFgBbRfzFCEj6uOP6QLL+ZoyWFOdCdcESkQgV9k sWJwWLUKt2eh4uxR5f3SbV24hOT/xj04KhdKt00SmUknpmuu0O/XB9n81NDDnjbl9PFn qey9KOt8W135I54LzBKth2dNhc9Vij5ai2J73gnGuMYQNohZsXUhgj/ZLGsF27789zs+ KiLx/XcwNY7DhUJGTeHVSuAcrLwaVrIYMNEPT9++PIkKm+Boy4mhvr8tqURsXfMz++DJ mXCvRxqwPBtHVXxCF9kqM+anBN3+4EQclU8Vqb4cYOfNFRxTUP4mC8NGv537sT1dDYUf genw== MIME-Version: 1.0 X-Received: by 10.107.161.197 with SMTP id k188mr7837742ioe.190.1440170753359; Fri, 21 Aug 2015 08:25:53 -0700 (PDT) In-Reply-To: References: Date: Fri, 21 Aug 2015 18:25:53 +0300 Message-ID: Subject: Re: dlopen() failure with ELOOP with legitimate dxe From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" To: djgpp Content-Type: text/plain; charset=UTF-8 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 8/21/15, Ozkan Sezer wrote: > There is a bug in dlopen() preventing dlopen()ing a dxe. > Here is the scenario, what we experienced with q2dos: > > ref_soft.dxe -> has no dependency dxes > ref_gl.dxe -> depends on gl.dxe (present) > gl.dxe -> depends on glide3x.dxe (not present) > > Start the exe, dlopen()s ref_soft.dxe -> OK, runs just fine. > > Do a dlclose() ref_soft.dxe, and attempt to dlopen() ref_gl.dxe: > fails, no surprise, (dlerror() misleadingly says ENOENT, but ok) > > The failure triggers dlopen()ing of ref_soft.dxe again: it fails > with ELOOP which is NOT expected because the dxe is there and it > is legitimate and it loaded and ran successfully the first time. > > As far as I can see, the "Load the dependencies" loop around line > 237 of dlopen.c does not reset stk_top upon failure which should > be the reason for failure of further dlopen() attempts? > Applied the following change to dlopen.c and the failure is gone: Index: dlopen.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/dxe/dlopen.c,v retrieving revision 1.8 diff -u -p -r1.8 dlopen.c --- dlopen.c 27 Jun 2015 12:21:06 -0000 1.8 +++ dlopen.c 21 Aug 2015 15:16:41 -0000 @@ -243,8 +243,10 @@ found: tmp.next = stk_top; stk_top = &tmp; - if (dlopen(scan, RTLD_GLOBAL) == NULL) + if (dlopen(scan, RTLD_GLOBAL) == NULL) { + stk_top = tmp.next; goto unrecoverable; + } stk_top = tmp.next; Comments? OK to apply? -- O.S.