From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3020 invoked by alias); 24 Jan 2003 21:28:39 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 3001 invoked from network); 24 Jan 2003 21:28:39 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by 172.16.49.205 with SMTP; 24 Jan 2003 21:28:39 -0000 Received: from Hermes.suse.de (Hermes.suse.de [213.95.15.136]) by Cantor.suse.de (Postfix) with ESMTP id ABD5D142D0 for ; Fri, 24 Jan 2003 22:28:38 +0100 (MET) To: libc-hacker@sources.redhat.com Subject: Re: Crash in DT_FINI_ARRAY X-Yow: Those aren't WINOS--that's my JUGGLER, my AERIALIST, my SWORD SWALLOWER, and my LATEX NOVELTY SUPPLIER!! From: Andreas Schwab Date: Fri, 24 Jan 2003 21:28:00 -0000 In-Reply-To: (Andreas Schwab's message of "Thu, 23 Jan 2003 14:08:20 +0100") Message-ID: User-Agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.3.50 (ia64-suse-linux) References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2003-01/txt/msg00169.txt.bz2 Roland asked me to create a test, and that promptly revealed another bug. Andreas. 2003-01-24 Andreas Schwab * elf/dl-close.c (_dl_close): Don't relocate DT_FINI_ARRAY elements, and process them backwards. * elf/Makefile ($(objpfx)tst-array4): New target. ($(objpfx)tst-array4.out): Likewise. (tests) [$(have-initfini-array) = yes]: Add tst-array4. * elf/tst-array4.c: New file. * elf/tst-array4.exp: Likewise. --- elf/Makefile.~1.254.~ 2003-01-16 11:19:30.000000000 +0100 +++ elf/Makefile 2003-01-24 21:40:51.000000000 +0100 @@ -121,7 +121,7 @@ endif tests = tst-tls1 tst-tls2 tst-tls9 ifeq (yes,$(have-initfini-array)) -tests += tst-array1 tst-array2 tst-array3 +tests += tst-array1 tst-array2 tst-array3 tst-array4 endif ifeq (yes,$(build-static)) tests-static = tst-tls1-static tst-tls2-static @@ -594,6 +594,12 @@ $(objpfx)tst-array3.out: $(objpfx)tst-ar $(objpfx)tst-array3 > $@ cmp $@ tst-array1.exp > /dev/null +$(objpfx)tst-array4: $(libdl) +$(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so + $(elf-objpfx)$(rtld-installed-name) \ + --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ + $< > $@ + cmp $@ tst-array4.exp > /dev/null check-textrel-CFLAGS = -O $(objpfx)check-textrel: check-textrel.c --- elf/dl-close.c.~1.93.~ 2003-01-16 11:19:32.000000000 +0100 +++ elf/dl-close.c 2003-01-24 22:16:12.000000000 +0100 @@ -238,10 +238,9 @@ _dl_close (void *_map) + imap->l_info[DT_FINI_ARRAY]->d_un.d_ptr); unsigned int sz = (imap->l_info[DT_FINI_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr))); - unsigned int cnt; - for (cnt = 0; cnt < sz; ++cnt) - ((fini_t) (imap->l_addr + array[cnt])) (); + while (sz-- > 0) + ((fini_t) array[sz]) (); } /* Next try the old-style destructor. */ --- /dev/null 2002-12-10 23:57:13.000000000 +0100 +++ elf/tst-array4.c 2003-01-24 20:46:10.000000000 +0100 @@ -0,0 +1,18 @@ +#include + +#define main array1_main +#include "tst-array1.c" +#undef main + +int +main (void) +{ + void *handle = dlopen ("tst-array2dep.so", RTLD_LAZY); + + array1_main (); + + if (handle != NULL) + dlclose (handle); + + return 0; +} --- /dev/null 2002-12-10 23:57:13.000000000 +0100 +++ elf/tst-array4.exp 2003-01-24 21:38:48.000000000 +0100 @@ -0,0 +1,19 @@ +preinit array 0 +preinit array 1 +preinit array 2 +init +init array 0 +init array 1 +init array 2 +DSO init +DSO init array 0 +DSO init array 1 +DSO init array 2 +DSO fini array 2 +DSO fini array 1 +DSO fini array 0 +DSO fini +fini array 2 +fini array 1 +fini array 0 +fini -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."